Using backup2l: Difference between revisions

From Sympl Wiki
Jump to navigation Jump to search
(Created page with "Sympl uses [https://github.com/gkiefer/backup2l backup2l] to manage backups, which happen automatically overnight. == Getting a Backup Summary == You can list a summary of th...")
 
No edit summary
 
Line 1: Line 1:
Sympl uses [https://github.com/gkiefer/backup2l backup2l] to manage backups, which happen automatically overnight.
Sympl uses [https://github.com/gkiefer/backup2l backup2l] to manage backups, which happen automatically overnight.


== Getting a Backup Summary ==
==Getting a Backup Summary==
You can list a summary of the backups with the command <code>backup2l -s</code>:
You can list a summary of the backups with the command <code>backup2l -s</code>:
  sympl@sympl:~$ backup2l -s
  sympl@sympl:~$ backup2l -s
Line 36: Line 36:
In the above example:
In the above example:


* there are two main backups labelled <code>all.1</code> and <code>all.2</code>.
*there are two main backups labelled <code>all.1</code> and <code>all.2</code>.


* <code>all.1</code> has five child backups, named <code>all.11</code> to <code>all.15</code>, taken weekly.
*<code>all.1</code> has five child backups, named <code>all.11</code> to <code>all.15</code>, taken weekly.
* <code>all.2</code> has three child backups named <code>all.21</code>, <code>all.22</code> and <code>all.23</code>, taken weekly.
*<code>all.2</code> has three child backups named <code>all.21</code>, <code>all.22</code> and <code>all.23</code>, taken weekly.
* <code>all.22</code> has a total of five child backups, named <code>all.221</code> to <code>all.225</code>, which are daily copies.
*<code>all.22</code> has a total of five child backups, named <code>all.221</code> to <code>all.225</code>, which are daily copies.
* <code>all.23</code> has a further three child backups, named <code>all.231</code> to <code>all.233</code>, including the most recent backup.
*<code>all.23</code> has a further three child backups, named <code>all.231</code> to <code>all.233</code>, including the most recent backup.


Each child backup is is overlaid on its parent and sibling backups, and only contains changes made since the last backup was run.
Each child backup is is overlaid on its parent and sibling backups, and only contains changes made since the last backup was run.


== Listing Backed Up Files ==
==Listing Backed Up Files==
To list files in a backup, you can use <code>backup2l -l</code> with an optional regular expression for match against specific files.
To list files in a backup, you can use <code>backup2l -l</code> with an optional regular expression for match against specific files.
  sympl@sympl:~$ backup2l -l 'site-logo'
  sympl@sympl:~$ backup2l -l 'site-logo'
Line 76: Line 76:
  All required archive files are present in /var/backups/localhost.
  All required archive files are present in /var/backups/localhost.


== Restoring From A Backup ==
==Restoring From A Backup==
<blockquote>Note that when recovering files, the recovered files retain their original paths, with the root in the current directory, so it's suggested you change directory to your home directory before starting a recovery.</blockquote>
<blockquote>Note that when recovering files, the recovered files retain their original paths, with the root in the current directory, so it's suggested you change directory to your home directory before starting a recovery.</blockquote>


=== Recovering From the Most Recent Backup ===
===Recovering From the Most Recent Backup===
To restore a file from backup2l, you should use <code>sudo backup2l -r</code>, with an optional [[regular expression]] for the files to recover. Not specifying a regular expression to recover will extract '''all of the content from your most recent backup''', so be wary of disk space or specify the files to recover.
To restore a file from backup2l, you should use <code>sudo backup2l -r</code>, with an optional [[regular expression]] for the files to recover. Not specifying a regular expression to recover will extract '''all of the content from your most recent backup''', so be wary of disk space or specify the files to recover.


Line 99: Line 99:
The resulting file can then be found in the <code>srv/example.com/public/htdocs/wp-content/uploads/2019/03/</code> directory from where you started the recovery.
The resulting file can then be found in the <code>srv/example.com/public/htdocs/wp-content/uploads/2019/03/</code> directory from where you started the recovery.


=== Recovering From a Specific Backup ===
===Recovering From a Specific Backup===
In some cases you may want to recover a specific version of the file not the most recent one. In that case you would use <code>backup2l -a</code> with the [[regular expression]] to list the copies available:
In some cases you may want to recover a specific version of the file not the most recent one. In that case you would use <code>backup2l -a</code> with the [[regular expression]] to list the copies available:
  sympl@sympl:~$ backup2l -a '/site-logo.png'
  sympl@sympl:~$ backup2l -a '/site-logo.png'
Line 123: Line 123:
    all.14.tar.gz: 1 file(s) using 'DRIVER_TAR_GZ'
    all.14.tar.gz: 1 file(s) using 'DRIVER_TAR_GZ'
As with recovering the most recent copy of a file, it will be placed with the root in your current directory.
As with recovering the most recent copy of a file, it will be placed with the root in your current directory.
[[Category:Backups]]
[[Category:Backup]]
[[Category:Third Party Software]]

Latest revision as of 15:43, 19 July 2019

Sympl uses backup2l to manage backups, which happen automatically overnight.

Getting a Backup Summary

You can list a summary of the backups with the command backup2l -s:

sympl@sympl:~$ backup2l -s
backup2l v1.6-pre2 by Gundolf Kiefer

Summary
=======

Backup       Date       Time  |  Size   | Skipped  Files+D |  New  Obs. | Err.
------------------------------------------------------------------------------
all.1        2019-05-23 07:07 |    1.4G |      51   160442 |160442    0 |    4
all.11       2019-05-29 06:27 |    7.3M |      51   161018 |  775   199 |    0
all.12       2019-06-04 06:54 |    7.4M |      51   161611 |  791   198 |    0
all.13       2019-06-10 07:15 |    8.5M |      51   162202 |  835   244 |    0
all.14       2019-06-16 06:55 |   61.1M |      51   163006 |21271 20467 |    4
all.15       2019-06-22 06:48 |   15.3M |      51   163430 | 1628  1204 |    0
all.2        2019-06-28 06:33 |    1.3G |      51   163260 |163260    0 |    0
all.21       2019-07-04 06:47 |   64.0M |      51   170123 |23037 16174 |    0
all.22       2019-07-10 07:09 |    3.3G |      57   861664 |692194  653 |    2
all.221      2019-07-11 06:47 |   32.9M |      57   865405 | 7740  3999 |    0
all.222      2019-07-12 06:42 |   61.4M |      57   870259 | 5787   933 |    0
all.223      2019-07-13 06:40 |   24.1M |      57   870355 |  930   834 |    0
all.224      2019-07-14 07:16 |   18.0M |      57   870457 |  880   778 |    0
all.225      2019-07-15 07:16 |   19.6M |      57   870552 |  873   778 |    0
all.23       2019-07-16 06:47 |   80.9M |      57   871091 |13827  4400 |    0
all.231      2019-07-17 07:03 |  226.3M |      57   885692 |28851 14250 |    0
all.232      2019-07-18 07:10 |   27.4M |      57   885777 |  998   913 |    0
all.233      2019-07-19 06:27 |   26.6M |      57   885791 | 1201  1187 |    2

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1       158G   22G  130G  15% /

Backups are taken daily, and as the backup task is the last of the 'daily' tasks in /etc/cron.daily/ it's normal for the backup times to vary a little.

In the above example:

  • there are two main backups labelled all.1 and all.2.
  • all.1 has five child backups, named all.11 to all.15, taken weekly.
  • all.2 has three child backups named all.21, all.22 and all.23, taken weekly.
  • all.22 has a total of five child backups, named all.221 to all.225, which are daily copies.
  • all.23 has a further three child backups, named all.231 to all.233, including the most recent backup.

Each child backup is is overlaid on its parent and sibling backups, and only contains changes made since the last backup was run.

Listing Backed Up Files

To list files in a backup, you can use backup2l -l with an optional regular expression for match against specific files.

sympl@sympl:~$ backup2l -l 'site-logo'
backup2l v1.6-pre2 by Gundolf Kiefer

Active files in <all.233>: 14
  found in all.233:        0   (   14 left)
  found in all.232:        0   (   14 left)
  found in all.231:        0   (   14 left)
  found in all.23:         2   (   12 left)
  found in all.22:         0   (   12 left)
  found in all.21:        12   (    0 left)

Listing locations...
all.23: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/cropped-site-logo-1-150x60.png
all.23: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/cropped-site-logo-1.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/cropped-site-logo-1024x239.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/cropped-site-logo-1200x280.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/cropped-site-logo-150x150.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/cropped-site-logo-300x70.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/cropped-site-logo-768x179.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/cropped-site-logo.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo-1024x231.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo-1200x271.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo-150x150.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo-300x68.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo-768x173.png
all.21: /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo.png

All required archive files are present in /var/backups/localhost.

Restoring From A Backup

Note that when recovering files, the recovered files retain their original paths, with the root in the current directory, so it's suggested you change directory to your home directory before starting a recovery.

Recovering From the Most Recent Backup

To restore a file from backup2l, you should use sudo backup2l -r, with an optional regular expression for the files to recover. Not specifying a regular expression to recover will extract all of the content from your most recent backup, so be wary of disk space or specify the files to recover.

Based on the above list of files, we want to recover only the site-logo.png file, so we specify more of the full path:

sympl@sympl:~$ sudo backup2l -r '/site-logo.png'
[sudo] password for sympl:
backup2l v1.6-pre2 by Gundolf Kiefer

Active files in <all.233>: 1
  found in all.233:        0   (    1 left)
  found in all.232:        0   (    1 left)
  found in all.231:        0   (    1 left)
  found in all.23:         0   (    1 left)
  found in all.22:         0   (    1 left)
  found in all.21:         1   (    0 left)

Restoring files...
  all.21.tar.gz: 1 file(s) using 'DRIVER_TAR_GZ'

The resulting file can then be found in the srv/example.com/public/htdocs/wp-content/uploads/2019/03/ directory from where you started the recovery.

Recovering From a Specific Backup

In some cases you may want to recover a specific version of the file not the most recent one. In that case you would use backup2l -a with the regular expression to list the copies available:

sympl@sympl:~$ backup2l -a '/site-logo.png'
backup2l v1.6-pre2 by Gundolf Kiefer

Listing available files...
all.1     +     1869 05/22/19 15:15:25 0033.0033 0664 /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo.png
all.14    -     1869 05/22/19 15:15:25 0033.0033 0664 /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo.png
all.14    +     1932 06/11/19 18:13:51 0033.0033 0664 /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo.png
all.2     +     1932 06/11/19 18:13:51 0033.0033 0664 /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo.png
all.21    -     1932 06/11/19 18:13:51 0033.0033 0664 /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo.png
all.21    +     2084 07/03/19 20:23:13 0033.0033 0664 /srv/example.com/public/htdocs/wp-content/uploads/2019/03/site-logo.png

Note that the versions are shown in the US date order (MM/DD/YY) but are still listed in order of their backup.

In the above example, the oldest backup was taken on 2019-05-22, then replaced on 2019-06-11, and replaced again on 2019-07-03.

To recover a specific version, you specify the backup set number, so to recover the second oldest copy from set all.14 on 2019-06-11, you would use:

sympl@sympl:~$ sudo backup2l -t all.14 -r '/site-logo.png'
backup2l v1.6-pre2 by Gundolf Kiefer

Active files in <all.14>: 7
  found in all.14:         1   (    0 left)

Restoring files...
  all.14.tar.gz: 1 file(s) using 'DRIVER_TAR_GZ'

As with recovering the most recent copy of a file, it will be placed with the root in your current directory.