Summary of progress with rsync
@Laszlo and I put forward some ideas for using rsync and tar for backups ( see Reply No 1)
In relation to rsync, I have been able to get some of the suggestions in Reply No 1 to work, but others have proved difficult. Tar has yet to be tested on live systems.
Here is a brief summary of progress and additional ideas, some from other users.
Things that worked for me
- backup a non-live system with rsync
mount /dev/sdxx /mnt/backup
rsync -axHAXS --exclude={/dev/*,/proc/*,/sys/*,/run/*,/mnt/*,/media/*,/tmp/*} /mnt/source/ /mnt/backup
Note the trailing / on the source directory, that ensures all files( including dot files) in source are copied.
- restore to a non-live system with rsync
mount /dev/sdxx -o ro /mnt/backup
mount /dev/sdyy /mnt/dest
rsync -axHAXS --delete --exclude={/dev/*,/proc/*,/sys/*,/run/*,/mnt/*,/media/*,/tmp/*} /mnt/backup/ /mnt/dest
Note the use of --delete. You do not have to delete the system being recovered to… rsync will wind it back to the backup state in terms of files and file dates and file ownership
- backup a live system with rsync
mount /dev/sdyy /mnt/backup
rsync -axHAXS --exclude={/dev/*,/proc/*,/sys/*,/run/*,/mnt/*,/media/*,/tmp/*} / /mnt/backup
Note it is very important to exclude /mnt/*. The / for source is OK, because it is a trailing slash.
It is important to close any running processes, and to exclude any active files like databases.
Prevent any updates from running.
The -x flag will exclude /home if it is a separate filesystem. (Thanks Rosika)
- restore to a live system with rsync
mount /dev/sdxx -o ro /mnt/backup
rsync -axHAXS --delete --exclude={/dev/*,/proc/*,/sys/*,/run/*,/mnt/*,/media/*,/tmp/*,/etc/mtab} /mnt/backup/ /
Note /etc/mtab is excluded. That came from a systemback example ( Thanks Laszlo).
It is important to exclude /mnt/*. Always mount the backup read-only. There is a trailing / on the source path.
- always do a dry run before you try an rsync
Example
rsync --dry-run -axHAXS --delete --exclude={/dev/*,/proc/*,/sys/*,/run/*,/mnt/*,/media/*,/tmp/*,/etc/mtab} /mnt/backup/ /
rsync -av --exclude-from=$EXL / $ARSYDIR/
Where $EXL is a filename containing a list of exclude criteria. ( Thank you Daniel)
Or like this
rsync -av --exclude-from=- /source/ /dest/ <<_EOF
/run
/proc
/sys
_EOF
(Thanks Laszlo).
Things that do not work for me
-
the --filter=protect_{/dev/*,...} option should protect directories from being deleted or owerwritten during a restore with --delete… in the same way as --exclude.
I tried it witjh a live restore and it crashed the live system.
-
in Peppermint/Devian OS an rsync of a live system does not properly terminate. It seems to not flush the ram buffers. A sync after the rsync rerminates hangs forever.
-
Not mounting the backup filesystem read only is a bad idea. One mistake with rsync and you can destroy your backup. I know, I did it twice. Slow learner.
Things not checked yet
-
leaving out -x to allow it to follow links to other filesystem. One might do this if /boot were a separate partition, or if /home were a separate partiton and one wanted to include it.
-
*systemback uses --include='* as well as –exclude=`. This to me seems unnecessaritly complicated but there may be reasons.
-
systemback excludes /etc/mtab for live recoveries. I have not tried without it, but I suspect it is necessaryfor a live system.
Thanks to all who have contributed, and to @easyt50 and @ihasama for suggesting the topic, and to @ihasama for having the courage to try rsync.
Suggested additions/corrections to summary welcome.