{"id":6,"date":"2009-06-19T01:57:46","date_gmt":"2009-06-18T21:57:46","guid":{"rendered":"http:\/\/avpsoft.ru\/blog\/?p=5"},"modified":"2017-02-15T13:40:08","modified_gmt":"2017-02-15T13:40:08","slug":"using-data-to-name-backup","status":"publish","type":"post","link":"https:\/\/avpsoft.com\/blog\/2009\/06\/19\/using-data-to-name-backup\/","title":{"rendered":"Using the &#8220;date format&#8221; to manage the structure of backup archives in APBackup"},"content":{"rendered":"<p>When saving a backup archive to the primary or additional folder, <a href=\"\/products\/apbackup\/\">APBackup<\/a> can name it according to the current date.  To enable this option, use the <strong>&#8220;Date format&#8221;<\/strong> field. This field is a date\/time mask and its value is calculated at the time a backup copy is created.<br \/>\n <!--more--><br \/>\n<code>For instance, if this field has the \"MMDDYYYY\" format, it will turn into\"06162009\" if the backup  process is started on June 16, 2009<\/code><br \/>\n<img class=\"aligncenter\" title=\"Backup archive settings\" src=\"\/blog\/wp-content\/uploads\/2009\/06\/save_backup.jpg\" alt=\" Backup archive settings\" \/><br \/>\nWhen saving an archive, APBackup first creates the main archive file and then, if additional folders have been specified, copies the archive there (up to 3 local folders and 1 remote folder on an FTP server are supported). You can also configure individual naming parameters and the <strong>archive depth<\/strong> for each additional folder.<br \/>\nThe <strong>archive depth<\/strong> parameter defines how APBackup deals with old archives. For instance, if the archive depth is 3 files, it means that APBackup will only leave the 3 latest backups after completing each backup task. You will also be able to set the depth in days and months \u2013 in this case, the program will only leave archives no older than 3 days, for example.<br \/>\nThe value of the &#8220;date format&#8221; field can be selected from the dropdown list or entered manually. The following macros are supported:<\/p>\n<ul>\n<li> c \u2013 Displays the date in the ShortDateFormat format and time in the LongTimeFormat format<\/li>\n<li> d \u2013 the day of the month without the leading zero (1-31).<\/li>\n<li> dd \u2013 the day of the month with a leading zero (01-31).<\/li>\n<li> ddd \u2013 the day of the week according to local settings (Sun-Sat)<\/li>\n<li> dddd \u2013 the complete day of the week (Sunday-Saturday)<\/li>\n<li> ddddd \u2013 the date only (without time) in the ShortDateFormat format<\/li>\n<li> dddddd \u2013 the date only (without time) in the LongDateFormat format<\/li>\n<li> m \u2013 the month without a leading zero (1-12). If m follows h or hh, minutes are displayed instead of months.<\/li>\n<li> mm \u2013 the month with a leading zero (1-12). ). If mm follows h or hh, minutes are displayed instead of months.<\/li>\n<li> mmm \u2013 the short name of the month according to local settings (Jan-Dec)<\/li>\n<li> mmmm \u2013 the full name of the month according to local settings (January-December)<\/li>\n<li> yy \u2013 year as two digits (00-99).<\/li>\n<li> yyyy \u2013 year as four digits (0000-9999).<\/li>\n<li> h \u2013 the hour without a leading zero (0-23).<\/li>\n<li> hh \u2013 the hour with a leading zero (00-23).<\/li>\n<li> n \u2013 minutes without a leading zero (0-59).<\/li>\n<li> nn \u2013 minutes with a leading zero (00-59).<\/li>\n<li> s &#8211; seconds without a leading zero (0-59).<\/li>\n<li> ss &#8211; seconds with a leading zero (00-59).<\/li>\n<li> t \u2013 time only in the short format.<\/li>\n<li>tt \u2013 time only in the full format.<\/li>\n<li>%dw \u2013 the number of the day of the week<\/li>\n<li> %dy \u2013 the number of the day of the year<\/li>\n<li> %wy \u2013 the number of the week of the year<\/li>\n<li> %wm \u2013 the number of the week of the month<\/li>\n<\/ul>\n<p>Below are some examples of the use of the date format for organizing the structure of backup copies in an archive.<\/p>\n<h3>The current archive + monthly archives.<\/h3>\n<p>We need to save the current daily backup with a depth of 4 days and save monthly backups with a 12-month depth in a separate folder.<br \/>\nThis can be accomplished using a single task only. An example of such task configuration is shown in the figure below.<br \/>\nIn this case, we need to configure the main archive to have the &#8220;YYYYMMDD&#8221; date format and the depth of 4 days. We will also need to set up an additional folder for monthly backups with the &#8220;YYYYMM&#8221; date format and the depth of 12 files. It\u2019s a better idea to save backups to different folders. If the main and secondary archives are saved to the same folder, you should set different prefixes for these archives, as the program will delete the files with the current prefix according to the backup depth parameter while cleaning up files after each backup.<br \/>\nNote the additional folder and the \u201cYYYYMM&#8221; time format \u2013 that is, the name of the archive will be the same every day, since the name mask will depend on the month and year only. Therefore, every new backup saved to the additional folder will overwrite the previous day\u2019s backup file. To avoid this, enable the &#8220;<strong>Do not overwrite if archive exists&#8221;<\/strong> option.  If the option is enabled and the program detects the same file in the additional folder, APBackup will not copy the file. So when the backup is made for the first time in a month, the program will create a backup archive in the additional folder (for example, on June 2, 2009, it will create an archive called 200906) and will not copy new archives to this folder until the end of the month.<br \/>\nAs the result, we will get 4 most recent daily backups and 12 backups made at the beginning of each month.<\/p>\n<h3>Sorting archives in a folder tree according to the date.<\/h3>\n<p>For instance, users copy different files to a certain folder. At the end of the day, you want to empty this category and back up the copied files \u2013 and it\u2019s necessary that the folder structure in the backup archive is preserved to make searching for files easier. For example, Backup&#92;2009&#92;6&#92;17&#92;bak.zip (however, just as in the previous example, the task mode (backup or copy) is absolutely unnecessary).<br \/>\nTo do that, just set the <strong>&#8220;backup prefix&#8221;<\/strong>value to &#8220;Backup&#8221; and the <strong>&#8220;date format&#8221; <\/strong> value to &#8220;YYYY&#92;MM&#92;DD&#92;bak&#8221;. To delete the source files, check the <strong>&#8220;Delete files after archiving&#8221;<\/strong> option on the &#8220;Sources&#8221; tab.<br \/>\nNow APBackup will create the necessary folder structure and copy the backup archive according to the current date daily when the backup task is started.<br \/>\nPlease note that &#8220;bak&#8221;, our archive file, does not contain the characters allowed in macros. This is done to prevent changes in the archive name, as it\u2019s specified in the \u201cDate format\u201d field.<br \/>\nIn this case, the <strong>archive depth<\/strong> parameter is taken into account and can be set to 12 months, for example.<br \/>\n<strong> <\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When saving a backup archive to the primary or additional folder, APBackup can name it according to the current date. To enable this option, use the &#8220;Date format&#8221; field. This field is a date\/time mask and its value is calculated at the time a backup copy is created.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[8,9,10,11,14],"_links":{"self":[{"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/posts\/6"}],"collection":[{"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":3,"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":421,"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions\/421"}],"wp:attachment":[{"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avpsoft.com\/blog\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}