Copy Only New or Updated Files on Linux

30/04/15 Permalink

Using cp

If you want to backup a folder from one location to another that may already contain the same files, then you can use the Linux cp command like this:

cp -u -v -r /home/username/files/* /media/username/disk/backup

The -u command means update - copy only if the file is newer or a fresh file, -v is for verbose (to display whats happening to the console), and -r is for recursive - to copy all folders within the input folder.

Using rsync

rsync is a powerful backup tool for Linux. To use rsync to backup files:

rsync -va --progress --exclude files/dontcopy* /home/username/files /media/username/disk/backup

rsync will automatically recognise that files are identical and skip them. The -va command means vverbose and archive, --progress shows progress, --exclude means exclude folders from the copy (the * is a wildcard to prevent subfolders being copied), and the last 2 arguments are [source folder] [destination folder].

Share It: Digg | del.icio.us | Furl | reddit | Facebook | Yahoo! | Send to Phone

mobile-utopia.com | Feedback