rsync two existing directories copying everything

5,223

Turns out I should have bitten the bullet... The dry run was just outputting the directories it explores but not the actual files.

I ran rsync for real and all was ok it skipped everything apart from the one or two new additions.

For reference this worked;

sudo rsync -avzs --ignore-existing --progress '/media/Storage/OSs/' 'User@MyDomain:/mnt/Storage/OSs/'
Share:
5,223

Related videos on Youtube

Alex
Author by

Alex

I am a software engineer for British Telecommunications mainly writing web and test automation apps in java/c#/javascript I graduated from the University of Bristol (England) with a Upper Second Class (2:1) Masters Degree in Electrical & Electronic Engineering. I also have experience with C, C++, Python and VBS

Updated on September 18, 2022

Comments

  • Alex
    Alex over 1 year

    I have two file servers in two locations. Currently both have the same data, which generally is unmodified (used for read only access).When the second server was set up (the one I'm sshing to) the data was copied over LAN and has since been moved geographically.

    I'm trying to use rsync for the first time on the required directories. An example command;

    sudo rsync -avz --ignore-existing -P --dry-run /media/Storage/OSs/ user@mydomain:/mnt/Storage/OSs/
    

    I've tried using -c -t -u (Additionally went on the remote server and updated the timestamps to today) also but every time I execute a dry run it wants to copy everything!

    Additionally the user is the same for both machines with the same UID.

    *Edit

    After playing around a bit more, I've found that rsync does not like the whitespace in the subdirectory names; For instance if I use ' to escape local shell & \ to escape remote shell

    sudo rsync -avz --ignore-existing -P '/media/Storage/OSs/Windows/Windows server 2011/' 'user@mydomain:/mnt/Storage/OSs/Windows/Windows\ server\ 2011/'

    Then all is well, my theory is then that rsync does not like the subdirectories with whitespaces. I have thousands of subdirectories; the only solution I can think of is to write a small python/shell script to run each sub directory separately but is undesirable.

    • Anders
      Anders about 10 years
      What messages do you get? Have you tried to sync something else, preferable small data set, to see if it works at all?
    • Alex
      Alex about 10 years
      Hi, yes I've tried a smaller sub directory with only a few items. Rsync works fine for directories when it was the original populator(unlike the current situation). I don't receive any error messages, only the normal verbose output (items sent, then summary at the end)
    • terdon
      terdon about 10 years
      Is rsync installed on both machines? Are the dates on both machines correct?
    • Alex
      Alex about 10 years
      Yes Rsync is on both machines, The date is correct on both (although the remote machine is approx 1minute behind the local machine)
    • Jacob Vlijm
      Jacob Vlijm about 10 years
      Hi Alex, whitespaces in the command (and thus in the backup directories) are problematic and the directory steps with whitespaces should be between '', but in subdirectories it should be no problem. it is the shell that does not like the whitespaces in the command.
    • Alex
      Alex about 10 years
      Hi yeah I found out using -s, '' for local & \ escaping for remote terminal will remove whitespace issues. The issue was that rsync was just outputting the directories it wanted to explore, when run for real it would look and find nothing to transfer. I didn't really want to run without knowing as I've 4TB of data which I couldn't really afford to pump over the www! Cheers anyway!
    • Anders
      Anders about 10 years
      You should probably install ntp and ntpdate to synchronize the times in each machine. Then the logs will be correct too, and some strange problems will not occur when you syncronize your machines.
    • Alex
      Alex about 10 years
      Thanks Anders, will do! I've always thought ubuntu automatically updated the time itself!