Sync two folders with commands in Linux

rsync -av --exclude='.git/' --exclude='*.*~' --include='*.org' /home/zw/code/org/ ~/code/siemens/org --delete
  • It puts folder /code/org ’s content into folder /code/siemens/org.

  • useful options

    • -a Do the sync preserving all filesystem attributes
    • -v run verbosely
    • –delete delete the files in target folder that do not exist in the source.
  • It could also sync two folders across different hosts

    rsync -av --exclude='.git/' --exclude='*.*~' --include='*.org' ~/code/my-site/content tester1@134.244.221.41:/home/tester1/my-site/content --delete
    
  • see: How to Use Rsync to Sync New or Changed/Modified Files in Linux

Frank Zhao
Frank Zhao
Computer Science Engineer

My interests include Compiler, distributed system and Symbolic Computation.

Related