rsync does that nicely, it can also do snapshots, but it cannot compress. For compression, you could use tar or dump but then you're looking at re-copying the contents of the entire hierarchy fresh each time the script is run. That is probably undesirable.
Basic rsync is from source to destination. The first time will be slow. Then any subsequent runs will copy only the changes.
Code:
rsync -av /home/foo/ /mnt/backup/foo/
If you want to remove files from the destination that no longer exist on the source, then use the --delete option in addition. See also --dry-run. Check the manual page for the full description of what those do and for a complete list of all features. There may be some others that you find useful.
If you want incremental backups using rsync, there are quite a few tutorials so you have a choice in finding one that makes sense to you or is close to the results you want.
Bookmarks