-
Notifications
You must be signed in to change notification settings - Fork 0
rsync
Marcel Schmalzl edited this page Jul 22, 2024
·
11 revisions
Sync and/or backup files. This is also very useful if you need to copy/update in increments and have automatic checks about the diff.
rsync will only delete files in the backup folder if and only if --delete is stated!
-
-a: archive mode = shortcut for:--recursive-
--links(cp symlinks) -
--perms(preserve permissions) -
--group(preserve group) -
--owner(preserve owner,suonly) --devices--specials-
-A/--acls(preserve ACLs) -
-X/--xattrs(preserve extended attributes) -
-aexcludes--hard-links(preserve hard links)
-
-c: compare based on checksum (not mod-time & size) -
-A: preseve access control lists (Linux permission management) (--acls) -
-X: preserve extended attributes (--xattrs) -
-v: verbose output (--verbose) -
-P: progress (--progress) -
-t: preserve modification times (--times) - `--include "filePattern"
- Example for recursive pattern:
--include "somePath**"
- Example for recursive pattern:
- `--exclude "filePattern"
- You can
--includesome area of interest and--exclude "*"everything else (note that the order is important)
- You can
- Compression
-
-z: Enable compression -
--zc=lz4[opt]: Compression choice/algorithm;rsync --versionshows available options -
--zl=7[opt]: Compression factor
-
-
--bwlimit=2000: Limit bandwith to value in kbps (small bursts may occur wich might overshoot); suffixes can be appended like20m -
--delete: compare source and backup directory; deletes files in backup directory if those are not present (anymore) in the source directory -
-u: skip files that are newer on the receiver (--update) -
-W,--whole-file: do not use the incrementalrsyncalgorithm; the whole file is sent as-is instead. Faster when the bandwidth between source and target machines is higher than the bandwidth to disk (especially when the "disk" is actually a networked file system). This is the default when both the source and target are on the local machine.
rsync -acAXvPt "$sourceFolder" "$backupFolder"rsync -rlcvPt "$sourceFolder" "$backupFolder"Add $(date +%Y%m%d) in path for timestamp (ex. outputFile=/var/my-backup-$(date +%Y%m%d).tgz)
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License *.
Code (snippets) are licensed under a MIT License *.
* Unless stated otherwise
