Backup – How to Automatically Archive a Directory

backup

I want to do one way synchronization.

I am having Folder A on my computer which is constantly updated with content.
Another Folder B is used for backup purpose which is on external HDD.

Now what I expect is that whatever extra which is present in folder A should go to folder B. However something which is present in B and NOT in A ""shall NOT be copied to A"".

In a nutshell, the backup folder may copy everything from the source folder, however nothing should be copied form backup folder to the source.

Best Answer

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

Related Question