-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsync.txt
41 lines (34 loc) · 2.36 KB
/
rsync.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# basic command:
rsync [flags] source target
# source and target can be ssh-style remote servers like user@domain:/path
# Trailing Slashes are important!
rsync /path/src\e[32;1;4m/\e[0m dest/ # copy the contents of src directory to the dest directory
rsync /path/src dest/ # copy the src directory *itself* into the dest directory, making dest/src/contents
# use --dry-run and --stats to test the effects before running it
# -a is kinda useful as a base template:
-a => --archive => "equals -rlptgoD (no -H,-A,-X)" (yeah)
-r Recursive
-l copy symLinks as symlinks (creates a symlink on the target, instead of copying the data the source link pointed to)
-p preserve Permissions
-t preserve modification Times
-g preserve Group -> if target rsync runs as super-user, or if the target rsync user is in that group
-o preserve Owner -> if target rsync runs as super-user
-D preserve device and special files (-D stands for '--devices --specials')
# it's often useful to also delete files on the target that no longer exist on the source, there's a bunch of
# options to tweak that (before/during/after transfer, also excluded files, also on IO errors (do not))
# NB: deleting files on the target that are not on the source might NOT be useful when rsync is used in a backup script!
# if the source got wiped, the first "backup" with --delete will remove the backup too.. so *unless* the backup medium
# has snapshots enabled, don't.
--del => --delete-during => "receiver deletes during the transfer" seems a safe default (for synchronizing)
# misleading option names:
--ignore-errors => refers to how --delete behaves, and will remove target files even if there were IO errors, so you can lose
last night's backup if there's source disk- or network glitches
--force => also refers to --delete, and will remove directories with contents on the target if they're no longer on the source
# progress
-v shows each file and directory
--progress shows \e[1mstats\e[0m on each file and directory, only use for debugging
--info=progress2 gives an ever changing summary and estimation of done and todo.
Using `pv` is possible but only with rsync -v and pv -l(ine count) -s $lines, as rsync doesn't use the STDIO streams that pv needs.
Also redirect stdout to /dev/null because pv still outputs all incoming data again.
### Logging ###
https://stackoverflow.com/a/12037164/126584