To break this up into parts, there are two major sections, followed by a summary and notes:
rsync -uva --delete /srv/bkp01 /srv/offbk2/
- the output redirection done by the shell running the rsync command:
rsync-command > ~/offbkp01.log
rsync - I assume this needs no explanation (but will provide if requested).
/srv/bkp01 - The source file or directory. There are some detailed rules on what it means if there is/isn't a slash on the end of the directory, and if the other directory exists. You can see the USAGE section of the man page for the details, but here the lack of a trailing slash means this directory will be copied into the destination, rather than this directory's contents being copied into the destination. Same if this is a file rather than a directory.
/srv/offbk2/ - The destination directory. In general, this will always be the last item listed in the rsync command section unless an option is used to specify it elsewhere in the command.
Shell's output redirection:
> - This redirects stdout (the standard output) from whatever is on the left to the file on the right, becoming its contents, and creating the file (if possible) if it does not already exist. Some notes:
- You can also redirect stderr (the standard error output) to the same file by adding
2>&1 to the very end of the command above. Order is important, so be careful generalizing where to put that. The magic number
1 refers to stdout,
2 refers to stderr,
& is (essentially) "the address of", and the full command snippet means "redirect the output of stderr into the stdout stream".
- If you want to append to the log file instead of replacing it, you can use
>> instead. The method to redirect stderr to the same place remains the same.
- You can send stdout and stderr to different places by using
1> stdout_file 2> stderr_file. You can also use
>> instead of
> in that command to do so by appending instead of replacing.
Shell variables / special symbols:
~ - This is shorthand for the current user's home directory, and forms part of the next bit.
~/offbkp01.log - the file offbkp01.log inside the current user's home directory. This is where the output of the rsync command will be put because of the redirection with
In summary, this command will:
- Copy all regular files, directories, symlinks, special files, and device files
- as well as most, if not all, important file attributes,
and it will delete anything in
/srv/offbk2/ that is not in
/srv/bkp01, with the following conditions:
- If a regular file, directory, or symlink(?) has a modification time on
/srv/offbk2/ that is newer than its modification time on
/srv/bkp01, it will not be updated, if both items are still the same type (regular file, directory, or symlink(?)).
Additionally, rsync will print out some information about what it is doing (specifically, which files are being transferred, and a final summary), which the shell will write into the file
~/offbkp01.log. That log file will be created anew if it does not already exist, and will be overwritten if it does already exist.
--fake-super is an option used to cause rsync to simulate super-user activities. It does this by using the files' extended attributes to store the attributes it could not set without having greater privileges. The real version of each attribute is set to whatever makes sense given the options and the privileges available. While this makes it convenient to make some backups even if you don't have super-user privileges, one should also note that it may pose a security risk greater than the use of rsync in general, as the real security attributes may not be set properly, even though the information about them was backed-up.
Source: lots of time working with rsync and reading its man-page.