A nice explanation of commands and output: http://stackoverflow.com/questions/4493525/rsync-what-means-the-f-on-rsync-logs
syntax:
$ rsync options source/ destination/
$ rsync -zuvira -e ssh . user@host:/that/path/
$ rsync -Piva --size-only path/ other_path/
OJO! The slashes at the end of paths are not trivial!
Source and destination could be either local or remote. In case of remote, specify the login name, remote server name and location.
rsync command common options:
--delete : delete files that don't exist on sender (system) -v : Verbose (try -vv for more detailed information) -e "ssh options" : specify the ssh as remote shell -a : archive mode, preserves user,group,time,permissions and symlinks for each file -r : recurse into directories -z : compress file data -l : copy symlinks as symlinks -i : displays item changes; and overwrites -u : skip files that are newer on the receiver, not overwrite -n : perform a trial run with no changes made Others: --existing : update but do not create new files --ignore-existing : create new, but do not update if already there --progress : shows transfer percentages --delete : deletes files in destination if not in source -W : send Whole file, not only incrementals, this is faster and needs more bandwith --list-only : just shows the list of files, no copying --include=PATTERN : include files matching --exclude=PATTERN : exclude files matching
Usage
Typical options woud be -zuvari (compressed, preserve time, show changed files, recursive, do not overwrite if newer).
This will copy the inventory folder to temp/: BE CAREFUL, THE SLASH AT THE END OF SOURCE MATTERS!
$ rsync -zivra /var/opt/installation/inventory /root/temp/
This will copy the *contents* of inventory folder within temp
$ rsync -zivra /var/opt/installation/inventory/ /root/temp
If you want to compare two folders before rsyncing
$ diff -qwir source destination
over ssh
Copy file from /www/backup.tar.gz to a remote server called host.org:
$ rsync -v -e ssh /www/backup.tar.gz user@host.org:~
the other way round:
rsync -v -e ssh user@host.org:~/backup.tar.gz /tmp/
understanding rsync logs
http://stackoverflow.com/questions/4493525/rsync-what-means-the-f-on-rsync-logs
Explanation of each bit position and value in
rsync's output:YXcstpoguax path/to/file
|||||||||||
||||||||||╰- x: The extended attribute information changed
|||||||||╰-- a: The ACL information changed
||||||||╰--- u: The u slot is reserved for future use
|||||||╰---- g: Group is different
||||||╰----- o: Owner is different
|||||╰------ p: Permission are different
||||╰------- t: Modification time is different
|||╰-------- s: Size is different
||╰--------- c: Different checksum (for regular files), or
|| changed value (for symlinks, devices, and special files)
|╰---------- the file type:
| f: for a file,
| d: for a directory,
| L: for a symlink,
| D: for a device,
| S: for a special file (e.g. named sockets and fifos)
╰----------- the type of update being done::
<: file is being transferred to the remote host (sent)
>: file is being transferred to the local host (received)
c: local change/creation for the item, such as:
- the creation of a directory
- the changing of a symlink,
- etc.
h: the item is a hard link to another item (requires
--hard-links).
.: the item is not being updated (though it might have
attributes that are being modified)
*: means that the rest of the itemized-output area contains
a message (e.g. "deleting")
Some example output from rsync for various scenarios:
>f+++++++++ some/dir/new-file.txt
.f....og..x some/dir/existing-file-with-changed-owner-and-group.txt
.f........x some/dir/existing-file-with-changed-unnamed-attribute.txt
>f...p....x some/dir/existing-file-with-changed-permissions.txt
>f..t..g..x some/dir/existing-file-with-changed-time-and-group.txt
>f.s......x some/dir/existing-file-with-changed-size.txt
>f.st.....x some/dir/existing-file-with-changed-size-and-time-stamp.txt
cd+++++++++ some/dir/new-directory/
.d....og... some/dir/existing-directory-with-changed-owner-and-group/
.d..t...... some/dir/existing-directory-with-different-time-stamp/
No comments:
Post a Comment