diff --git a/blog/backup-with-rdiff.html b/blog/backup-with-rdiff.html index d276027..139fa32 100644 --- a/blog/backup-with-rdiff.html +++ b/blog/backup-with-rdiff.html @@ -30,11 +30,17 @@
-

Like rsync, rdiff-backup is a tool used for incremental backups. Unlike rsync, however rdiff keeps the most-recent file, along with any changes, deletions, etc.

+

Like rsync, rdiff-backup is a tool used for incremental backups. Unlike rsync however, rdiff keeps the most-recent file change, along with any previous changes, deletions, etc.

Install

+
sudo apt install rdiff-backup

Backup

+
rdiff-backup $dir $backup

Restore

+
rdiff-backup -r 2D $backup $restore_dir

Advanced

+

Only keep backups for a certain time period

+
rdiff-backup --force --remove-older-than 2M $backup
+

This will remove all backups older than 2 months from $backup.

diff --git a/blog/backup-with-rsync.html b/blog/backup-with-rsync.html index f6df7e0..f84267e 100644 --- a/blog/backup-with-rsync.html +++ b/blog/backup-with-rsync.html @@ -30,11 +30,48 @@
-

rsync

+

Rsync is a program that allows for incremental backups. This means that rsync will not create an additional copy of the data when backing up, it will only backup changes to the files/directories, saving bandwidth and storage space.

+

Installation

+
sudo apt install rsync
+

Backup

+
rsync -azh $ORIGINAL $BACKUP
+

Replace $ORIGINAL with the file/directory to backup, and $BACKUP with the location for the backup to reside.

+

The $BACKUP destination must be a blank directory, an rsync directory, or not currently exist.

+ +

Remote rsync backup

+

If you need to rsync from one PC to another, it's essential the same command, but with the additional layer of ssh

+
rsync -azh -e ssh $ORIGINAL $BACKUP
+

$BACKUP here will be an ssh connection pointed to a location, much like when using scp, so the command will look like

+
rsync -azh -e ssh $ORIGINAL $USER@$HOST:$LOCATION
+

Replacing $USER and $HOST with the username and hostname/IP for the server

+

Restore

-

Advanced

+

A restore in rsync doesn't require any rsync code per-se, as you can just copy individual files from the backup location to the restore location.

+

Alternatively to restore the entire directory, keeping files that haven't changes, and those that have to the time of the last backup, rsync can do that as below

+
rsync -auv $BACKUP $RESTORE
+

Over the internet

+

Like with backups, these restores can be done over the network/internet too

+
rsync -auv $USER@$HOST:$BACKUP $RESTORE
+ +

Notes/Advanced

+

+-r recursive. All files/directories in the path will be backed up
+-a archive mode. Recursive, but with file permissions, symlinks, etc retained.
+-z compress
+-b backups
+-R relative
+-u update - copy only changed files
+-P progress
+-c compress
+-p preserve permissions
+-h human readable. Make the output readible by humans
+
+ +

Downsides

+

Rsync only keeps one copy of the data, and doesn't keep the changes that were made, making it impossible* to restore a file's contents from the day previous. If this is what you're after, look at rdiff-backup.

+

* Not impossible, as you can set rsync to do this, but it requires a bit of scripting, and isn't as easy as just running the program