How to automatically archive a directory?

Sounds like a perfect task for rsync

sudo rsync -az /path_to/A /path_to/B

-a archive mode (implies recursive, copy symlinks as symlinks, preserve owner, modification times, group, owner, special and device files)

-z compresses the data

If you wish to remove files deleted in A from files in B, use the --delete option

For additional information see:

https://help.ubuntu.com/community/rsync

You can run rsync from cron

sudo crontab -e

Add in an hourly task

@hourly rsync /path_to/A /path_to/B

https://help.ubuntu.com/community/CronHowto


I'd suggest using rsync for this purpose. Rsync is extremely fast, stable, and versatile. There's a good introduction at http://help.ubuntu.com/community/rsync

If you wish, there is an optional graphic front end: grsync

 sudo rsync -azv --exclude 'dir1' /home/path/folderA/ /home/path/folderB

The command above will copy from folderA to folderB excluding dir1. The flags are

-a preserves time stamps
-z is to enable compression
-v verbose

There are many more options available.


I always found Unison to be very helpful. It has a text based or GUI based interface, and quite a few different options to tweak it to what you want (with a little fiddling). It takes quite a bit of time to do the first sync, but after that it's brilliant. You can make it sync one-way, as you want, but it will pretty much get that automatically. It can also delete from the backup or not as you choose.

You also may find issues with permissions which are supported in the ubuntu file format, but maybe not in the external hard drive (depending whether the external hard drive is going to be used in a windows machine, this may be a good thing), so you'll want to sync without the permissions potentially.

Anyway, the nice thing is that with the tutorial it's relatively straightforward to set it up once, and thereafter it's a GUI interface whenever you want to do it.

Here's some info about it: http://www.ubuntugeek.com/unison-file-synchronization-tool.html

And here's the tutorial: http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#tutorial

Tags:

Backup