sync two folders
Make one folder a copy of another, here or on a server, copying only what changed.
danger Steps marked in red delete, overwrite or stop something. Read each one before you run it.
Steps
-
rsync -avn --delete src/ dest/danger show what would change, without changing anything
-
rsync -av --delete src/ dest/danger make dest the same as src, deleting what src does not have
-
rsync -avz src/ NAME@host:/backup/src/to a server, compressed on the way
-
rsync -av --progress src/ dest/copy only, deleting nothing, with progress
Notes
- --delete removes files from dest: run the -n line first.
Commands used
rsync
Each has a page in lore: lore rsync opens it.
Related recipes
- copy files to and from a serverCopy a file or a whole folder between this machine and another one over ssh.
- download a whole folder from a websiteFetch every file under a web folder, without climbing to the folders above it.
- add to the end of a fileAdd lines to a file without replacing it, also to a file only root can write.
- argument list too long"Argument list too long" from rm, cp or mv: too many files for one command line. Hand them over in batches.