Skip to content

Instantly share code, notes, and snippets.

@M4lF3s
Last active June 14, 2022 10:37
Show Gist options
  • Save M4lF3s/0c40463186d26d35ecaaf4bf1d0573bf to your computer and use it in GitHub Desktop.
Save M4lF3s/0c40463186d26d35ecaaf4bf1d0573bf to your computer and use it in GitHub Desktop.
NAS Backup Commands
#
# Compare 2 Directories
#
nohup diff -r --no-dereference a b > mycommand.out 2>&1 &
#
# Backup with rsync
#
# The command will copy/sync all the files and directories present in directory foo to directory bar.
# If the destination directory is not present (here bar), rsync automatically creates one and copies all the data in it.
#
# -a, –-archive: This is equivalent to using -rlptgoD. Archive mode includes all the necessary options like copying files
# recursively, preserving almost everything (like symbolic links, file permissions, user & group ownership
# and timestamps).
# -v, –-verbose: By default, rsync works silently. A single -v will give us information about what files are being
# transferred and a brief summary about the data transferred at the end. Two -v options will give us
# information on the status of delta-transmission and on what files are up to date so as to be skipped and
# slightly more information at the end.
# -h, –-human-readable format: Outputs in a human readable format
# -z, –-compress: Compress file data during the transfer (More useful for remote transmission)
# -e: Specifies Protocol
#
rsync -avh --progress /foo /bar
rsync -avhze ssh /foo user@remote-host:/tmp/
rsync -avhe ssh --chown=USER:GROUP /foo user@remote-host:/tmp/
#
# --update: Files that do not exist on the remote-host are copied.
# Files that exist on both local and remote but have a newer
# timestamp on the local-host are copied to remote-host.
#
rsync -avhe ssh --progress --update /foo root@remote-host:/tmp/
# To future me: Keep in mind that this actually creates a folder "foo" in /tmp/ !!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment