Linux: Sync Across Machines, rsync
rsync is a command line util that lets you do one-way copying/updating from one machine to another.
The remote machine must also have rsync installed. (it's installed by default in linux)
rsync -z -a -v -t --rsh="ssh -l joe" ~/web/ firstname.lastname@example.org:~/
This will copy the local dir
~/web/ to the remote dir
~/ on the machine with domain name “example.org”, using login “joe” via the ssh protocol.
Here's what the options mean:
-a→ archived mode, basically making the file's meta data (owner/perm/timestamp) same as the local file (when possible) and do recursive (i.e. Upload the whole dir).
-z→ use compression for transmission. (compress files first, transmit, uncompress. This saves bandwidth.)
-v→ verbose mode. Print out which files is being updated.
-t→ copy timestamp from source to destination. If you don't, rsync will basically update every file. Timestamp is used by rsync to check if file's been updated.
For example, here's what i use to sync/upload my website on my local machine to my server.
rsync -z -a -v -t --exclude="*~" --exclude=".DS_Store" --exclude=".bash_history" --exclude="*/_curves_robert_yates/*.png" --exclude="logs/*" --exclude="xlogs/*" --delete --rsh="ssh -l joe" ~/web/ email@example.com:~/
--exclude=glob_pattern→ ignore file names that matches glob_pattern in source directory. (i.e. if it matches, don't upload it, nor delete it on remote server) For example,
*.javacmeans all files ending in
--delete→ if a file/dir in destination is not in source directory, delete it.
Here's a example of syncing Windows and Mac.
rsync -z -r -v --delete --rsh="ssh -l xah" ~/web/ firstname.lastname@example.org:~/web/
-r is used instead of
-r means recursive, all sub directories and files. Don't use
-a because that will sync file owner, group, permissions, and others, but because Windows and unix have different permission systems and file systems, so
-a is usually not what you want.
[see Linux: File Permission System]
Here's a example of reverse direction.
rsync -z -a -v -t --rsh="ssh -l joe" email@example.com:~/web/ ~/
This will get everything from the remote machine, to local machine.
Two-way Synchronize with Unison
How to Use Unison for Syncing Files (Unison tutorial)
Downloading a Entire Website
Linux: Download Website: wget, curl
[see Linux: Compare Files or Directory: diff]
Linux Shell Basics
- Get System Info
- Shell Basics
- grep, cat, awk, uniq
- find, xargs
- diff Files/Dir
- dir size: du
- dir tree
- tar gzip bzip2 xz 7zip rar zip
- wget, curl, GET, HEAD
- Install Packages
- Job Control
- RAM stat
- Users and Groups
- File Permission
- Opened Files: lsof
- shutdown, sleep
- Bash Keys, Terminal Keys, Man Page Keys
- Bash Prompt Setup
- Bash Color Prompt
- .bashrc, .profile, .bash_profile
- Virtual Console
- Terminal Control Sequence Keys
- Reset Terminal
- man page
- Bash Manual in Chapters
- BASH Shell Misc Tips
- Log Terminal Session
- Most Useful GUI Apps
- Set Default App
- Shell Commands for GUI Apps
- Image Viewers
- Music Players
- Move File to Trash by Command
- X11 Selection and Clipboard
- How to Switch to LXDE, Xfce
- LXDE Keyboard Shortcuts
- LXDE/Openbox, Change Keyboard Shortcuts
- LXDE Set Key Repeat Rate
- LXDE/OpenBox, Disable Mouse Scroll Wheel Hide Window
- Xfce Keyboard Shortcuts
- Xfce Good Themes
- xmonad Keybinding
- How to Restart X11
- Why Tiling Window Manager Sucks
- Standard Fonts
- How to Install Font
If you have a question, put $5 at patreon and message me.