Back up with rdiff
Use the rdiff tool for backup operations.
Read time 2 minutesLast updated 21 days ago
Use
rdiffrdiffdst tmp auxrdiffrdiffrdiff-backupdst tmp auxtar.gzweek_xxtar.gzCommands
Create backups
Create a backup. If you reuse the target path, you create an incremental backup.sudo rdiff-backup "/media/codice/New Volume/jet_ubuntu" "/media/codice/New Volume/rdiff_backups/"
List backups
List the incremental backups stored that you can restore them later:sudo rdiff-backup --list-increments "/media/codice/New Volume/rdiff_backups/rep_4"[sudo] password for codice:Found 3 increments:rep_4.2017-01-16T08:28:58-08:00.dir Mon Jan 16 08:28:58 2017rep_4.2017-01-16T09:34:15-08:00.dir Mon Jan 16 09:34:15 2017rep_4.2017-01-17T01:54:14-08:00.dir Tue Jan 17 01:54:14 2017Current mirror: Tue Jan 17 02:01:13 2017
Restore an incremental backup
The following command restores the last backup prior to 8 hours and 30 minutes ago. The example uses the--tempdirsudo rdiff-backup -r 8h30m --force --tempdir "/media/codice/New Volume/tmp_path" "/media/codice/NewVolume/rdiff_backups/rep_4" "/media/codice/New Volume/jet_ubuntu/rep_4"
Cold copy example
This example shows the setup for a weekly and incremental backup usingrdiff-backup- Install in your server.
rdiff-backup 1.2.8 - Configure to auto mount backup
autofsfolder in theNFSfolder./cifs/backup - Add a cron job that executes everyday at 3:30 AM local time:
#!/bin/bashexport weekNumber='date +%V'export year='date +%Y'export today='date +%Y%m%d'export lastActinLogFile="/root/backup_jet.log"export dirName="week_$weekNumber"export baseBackupDstLocation="/cifs/backup/backups/myserver_jet"export backupFinalDstLocation="$baseBackupDstLocation/$year/$dirName"export weekIncrementsTarGzDstFile=$backupFinalDstLocation/myserver_ddbb_jetfs.rdiff-backup_$year_week_$weekNumber.tar.gz#rdiff-backup source and destination paramsexport srcJetFolder="/home/mydata/jet"#export rdiffBackupWeekIncrementsAuxDir="/home/mydata/local_jet_backup_rsync"export rdiffBackupWeekIncrementsAuxDir="$baseBackupDstLocation/tmp"echo "starting daily backup $today on dst dir: $backupFinalDstLocation" > $lastActionLogFile#when a new week starts, reset the increments dst dir so rdiff-backup starts a fresh backup from scratchif [ ! -d "$backupFinalDstLocation" ]; then mkdir -p $backupFinalDstLocation #reset weekly backup local folder rm -rf $rdiffBackupWeekIncrementsAuxDirfiecho "about to stop and targz $today" > $lastActionLogFile/usr/sbin/plasticsd stopsleep 20rdiff-backup $srcJetFolder $rdiffBackupWeekIncrementsAuxDirrm $weekIncrementsTarGzDstFiletar cvzf $weekIncrementsTarGzDstFile $rdiffBackupWeekIncrementsAuxDirsleep 20/usr/sbin/plasticsd startecho "done! $today" > $lastActionLogFile
Hot copy example
As this is a hot copy, you need to switch the server between normal and read-only modes (cm admin readonly- Install in your server.
rdiff-backup 1.2.8 - Configure to automount backup
autofsfolder in theNFSfolder./cifs/backup - Add a cron job:
#!/bin/bashexport weekNumber='date +%V'export year='date +%Y'export today='date +%Y%m%d'export lastActinLogFile="/root/backup_jet.log"export dirName="week_$weekNumber"export baseBackupDstLocation="/cifs/backup/backups/myserver_jet"export backupFinalDstLocation="$baseBackupDstLocation/$year/$dirName"export weekIncrementsTarGzDstFile=$backupFinalDstLocation/myserver_ddbb_jetfs.rdiff-backup_$year_week_$weekNumber.tar.gz#rdiff-backup source and destination paramsexport srcJetFolder="/home/mydata/jet"export rdiffBackupWeekIncrementsAuxDir="$baseBackupDstLocation/tmp"echo "starting daily backup $today on dst dir: $backupFinalDstLocation" > $lastActionLogFile#when a new week starts, reset the increments dst dir so rdiff-backup starts a fresh backup from scratchif [ ! -d "$backupFinalDstLocation" ]; then mkdir -p $backupFinalDstLocation #reset weekly backup local folder rm -rf $rdiffBackupWeekIncrementsAuxDirfiecho "about to stop and targz $today" > $lastActionLogFilecm admin readonly entersleep 20rdiff-backup $srcJetFolder $rdiffBackupWeekIncrementsAuxDirrm $weekIncrementsTarGzDstFiletar cvzf $weekIncrementsTarGzDstFile $rdiffBackupWeekIncrementsAuxDirsleep 20cm admin readonly leaveecho "done! $today" > $lastActionLogFile