Backup with rsync over ssh Rsync is used if there are destination files already (how to handle them) For simply moving and copying to an emtpy location, cp and mv will do
#! /bin/bash
# archive mode, be verbose, use compression, preserve partial files, display progress
rsync -avvzhxP /source /destination/
# turn off compression for local transfers (more for network/internet)
# remote
rsync -avzPe "ssh -i ssh-priv.key" user@server:/data/dir destination/
# options
--ignore-existing # only copy if file doesnt exist yet (filename)
--update # only copy if local file is newer (filedate)
--remove-source-files # move files to remote
rsync -aH -e ssh --delete --exclude Cache --link-dest=yesterdaystargetdir remote1:sourcedir todaystargetdir
-a archive = -rlptgoD
-r recurse into dirs
-l cp symlinks as symlinks
-p preserve permissions
-t prsv. times
-g prsv. groups
-o prsv. owner
-D prsv. device and special files
-h human readable
-q quiet
-u update = skip files that are newer on the receiver
-H prsv. hard-links
-n dry run
—delete delete files from receiver if missing in src
—exclude=dir
—partial keep partially transf. files
-P = —partial und —progress
—link-dest=dir link to previous increment
--log-file=
# usually rsync checks file size and time as heuristic
--ignore-times # ignores size and time, thus transfers all files unconditionally (either delta or --whole-file)
--checksum # only examines size, if size is equal md5 checksum is compared (read whole files)
--checksum
--stats # show stats summary at the end
# Playing with compression
# - Compression over local network (wifi or ethernet) will probably not increase performance!
# https://unix.stackexchange.com/a/292020
# - For a very large amount of small files you might want to consider bundling them (tar) before sending (be careful, a lot of rsync features will not work this way!)
# https://bash-prompt.net/guides/bash-rsync-speedup/
# https://unix.stackexchange.com/questions/30953/tar-rsync-untar-any-speed-benefit-over-just-rsync
# - Using ssh rather than samba might also be faster!