Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sync without scanning individual files? [closed]

Consider two directories:

/home/user/music/flac
/media/MUSIC/flac

I would like the second directory (destination; a USB drive) to contain the same files and structure as the first directory (master). There are 3600+ files (59G in total). Every file is scanned using unison, which is painfully slow. I would rather it compare based on file name, size, and modification time.

I think rsync might be better but the examples from the man pages are rather cryptic, and Google searches did not reveal any simple, insightful examples. I would rather not accidentally erase files in the master. ;-)

The master list will change over time: directories reorganized, new files added, and existing files updated (e.g., re-tagging). Usually the changes are minor; taking hours to complete a synchronization strikes me as sub-optimal.

What is the exact command to sync the destination directory with the master?

The command should copy new files, reorganize moved files (or delete then copy), and copy changed files (based on date). The destination files should have their timestamp set to the master's timestamp.

like image 933
Dave Jarvis Avatar asked Aug 13 '09 22:08

Dave Jarvis


1 Answers

You can use rsync this way:

rsync --delete -r -u /home/user/music/flac/* /media/MUSIC/flac

It will delete files in /media/MUSIC/flac (never on master), and update based on file date.

There are more options, but I think this way is sufficient for you. :-)

(I just did simple tests! Please test better!)

like image 165
oznek Avatar answered Oct 06 '22 13:10

oznek