Rsync

From Alessandro's Wiki
Revision as of 07:32, 9 October 2020 by Porcelinux (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  • some options
  1. -x one filesystem
  2. -X xattr
  3. -z compress
  4. -H preserve hard links
  5. -c checksum
  6. --delete remove deleted files from destination
  7. --delete-excluded


  • sync a directory, deleting deleted files from destination
rsync --progress --delete -avP srv::home /mnt/mirror/home/
  • Specify a port for the ssh connection:
rsync --rsh='ssh -p2222' <sourcefile> user@host:/destination/directory
#!/bin/sh

date=`date "+%Y-%m-%dT%H_%M_%S"`
HOME=/home/user/

rsync -azP \
  --delete \
  --delete-excluded \
  --exclude-from=$HOME/.rsync/exclude \
  --link-dest=../current \
  $HOME user@backupserver:Backups/incomplete_back-$date \
  && ssh user@backupserver \
  "mv Backups/incomplete_back-$date Backups/back-$date \
  && rm -f Backups/current \
  && ln -s back-$date Backups/current"