back Backup with rsync
comp
publication: Julho 15 2021 14:06
last update: Julho 15 2021 14:06
rsync for incremental backup
rsync -acH --exclude=$EXCLUDE --delete --link-dest=$LAST_BACKUP_DIR \
$SOURCE_DIR/ $NEW_BACKUP_DIR
where
-a: archive mode; equals -rlptgoD (no -H,-A,-X)
-c: skip based on checksum, not mod-time & size
-H: preserve hard links
--exclude: exclude files matching $EXCLUDE
--delete: delete extraneous files from dest dirs
--link-dest: hardlink to files in $LAST_BACKUP_DIR when unchanged
Script:
1 2 3 4 5 6 7 8 9 10 |
|
transfering files
rsync -zacH --rsync-path="sudo rsync" --link-dest=$BACKUP_DIR \
user@remote_server:/mnt/backup/ $BACKUP_DIR
where
-z: compress file data during the transfer
-a: archive mode; equals -rlptgoD (no -H,-A,-X)
-c: skip based on checksum, not mod-time & size
-H: preserve hard links
--rsync-path: specify the rsync to run on remote machine
--link-dest: hardlink to files in $BACKUP_DIR when unchanged
Notice the trick to call rsync using sudo in the remote machine in case you need it.
source: https://linuxconfig.org/how-to-create-incremental-backups-using-rsync-on-linux