Skip to content

Instantly share code, notes, and snippets.

@kuanyui
Last active March 3, 2023 06:14
Show Gist options
  • Save kuanyui/fd1d8dcac9060e65f142c9fe7f89de3b to your computer and use it in GitHub Desktop.
Save kuanyui/fd1d8dcac9060e65f142c9fe7f89de3b to your computer and use it in GitHub Desktop.
my alias for rsync
function init_rsync() {
# --archive, -a archive mode is -rlptgoD (no -A,-X,-U,-N,-H)
# --recursive, -r recurse into directories
# --links, -l copy symlinks as symlinks
# --perms, -p preserve permissions
# --times, -t preserve modification times
# --group, -g preserve group
# --owner, -o preserve owner (super-user only)
# -D same as --devices --specials
# --devices preserve device files (super-user only)
# --specials preserve special files
local OPT_ARCHIVE=" --recursive --links --perms --times --group --owner --devices --specials "
# --atimes, -U preserve access (use) times
## --crtimes, -N preserve create times (newness) -- Not Supportted?
# --xattrs, -X preserve extended attributes
# --executability, -E preserve executability
# --whole-file, -W copy files whole (w/o delta-xfer algorithm) https://unix.stackexchange.com/questions/723309/rsync-whole-file-explained
local OPT_OTHER=" --atimes --xattrs --executability --whole-file "
local OPT_LOG=" --verbose --human-readable --stats --progress "
local OPT_EXCLUDE=' --exclude="/.cache/" --exclude="/.wine/" '
local COMMON_OPTS=" ${OPT_ARCHIVE} ${OPT_OTHER} ${OPT_LOG} ${OPT_EXCLUDE} "
alias rsync-backup="sudo rsync ${COMMON_OPTS}"
alias rsync-backup-dry-run="rsync --dry-run ${COMMON_OPTS}"
}
init_rsync
unset -f init_rsync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment