Rsync: Difference between revisions
From Jedisaber Wiki
| Line 34: | Line 34: | ||
<ol> | <ol> | ||
<li>[http://man.he.net/?topic=rsync§ion=all rsync man page]</li> | <li>[http://man.he.net/?topic=rsync§ion=all rsync man page]</li> | ||
<li> | <li>[https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps Digital Ocean How to Use rsync]</li> | ||
</ol> | </ol> | ||
Revision as of 19:25, 27 February 2017
rsync copies files and directories. It is often used for backups, or duplicating directory contents on a remote server. rsync can copy only changed files, and can use SSH to securely copy the file.
Common Options
-a - Combo flag, same as -rlptgoD (recursive; copies symlinks; preserve: permissions, modification times, group, and owner; device/special)
-v - verbose
-n - do a "dry run". Together with -v, -n shows what rsync will copy, but doesn't actually copy anything
dir vs dir/:
dir - Copy the directory
dir/ - Copy the contents of the directory
Sync Directories on the same computer
rsync -a dir1/ dir2 - Copies the contents of dir1 into dir2
Copy files to a remote system
Specify the directory you want to copy, then the destination.
rsync -a /dir1 username@remote_host:destination_directory
Example:
rsync -a /docs bob@example.com:/home/bob/public_html- Copies the entire directory "docs" into directory /home/bob/public_html on the server.
You can reverse this to copy from the remote system to the local computer.
Example:
rsync -a bob@example.com:/home/bob/public_html/docs/ /home/bob/web_files/docs - Copies the contents of /home/bob/public_html/docs/ into the local directory /home/bob/web_files/docs
