1

How do I write a script which creates incremental backups using rsync or what are the parameters to do the incremental backup?

Here's the scenario:

I have a samba file server and I need to backup to usb external drive any changes or additional files created on a specific samba folder. Location of files that I need backup (/opt/Resources and /opt/Resources Shared Folder 2) and the destination (/media/disk/Resources Files Backup).

I tried to create a file (zipfiletest) on /opt/Resources and manually run rsync to see if the file transfer to the usb external hard drive, it seems it works but I don't know how to do it automatically if ever there's a new file created or modified from the samba source.

[root@fileserver Resources]# rsync -azv /opt/Resources/zipfiletest /media/disk/Resources\ Files\ Backup01292013/Resources
sending incremental file list
zipfiletest/

sent 47 bytes  received 16 bytes  126.00 bytes/sec
total size is 0  speedup is 0.00

3 Answers 3

1

rsync can create hardlinks to files in another directory. So when you backup to directory containing current date in it's name, you can pass --link-dest argument pointing to previous backup. In result you will have two identical (if there was no change between backups) directories that take up space only for one.

Another solution is called rdiff-backup. It uses rsync protocol and handles incrementals for you. It uses some extra files to store diff to older versions (no hardlinks). I use it and it works nicely, but when comes to restoring old versions, it is slow.

0

Here's how I solved my own question.

From Samba File Server:

Source:

/opt/Resources
/opt/Resources Shared Folder 2

Destination:

/media/disk/Resources Files Backup/Resources
/media/disk/Resources Files Backup/Resources Shared Folder 2

Script:

backup.sh

rsync -azv /opt/{Resources,Resources\ Shared\ Folder\ 2/} /media/disk/Resources\ Files\ Backup/Resources/

Location of backup script:

/usr/local/bin

crontab run at midnight of every day

0 0 * * * /usr/local/bin/backup.sh
0

From http://rdiff-backup.nongnu.org/

A remote incremental backup of all your files could be as easy as "rdiff-backup / host.net::/target-dir"[disclaimer] What is it?

rdiff-backup backs up one directory to another, possibly over a network. The target directory ends up a copy of the source directory, but extra reverse diffs are stored in a special subdirectory of that target directory, so you can still recover files lost some time ago. The idea is to combine the best features of a mirror and an incremental backup. rdiff-backup also preserves subdirectories, hard links, dev files, permissions, uid/gid ownership, modification times, extended attributes, acls, and resource forks. Also, rdiff-backup can operate in a bandwidth efficient manner over a pipe, like rsync. Thus you can use rdiff-backup and ssh to securely back a hard drive up to a remote location, and only the differences will be transmitted. Finally, rdiff-backup is easy to use and settings have sensical defaults.

You must log in to answer this question.