Skip to content

Instantly share code, notes, and snippets.

@STrRedWolf
Created October 30, 2020 13:48
Show Gist options
  • Save STrRedWolf/30da44ce701fbd5034c5f80fda83bffc to your computer and use it in GitHub Desktop.
Save STrRedWolf/30da44ce701fbd5034c5f80fda83bffc to your computer and use it in GitHub Desktop.
Time Machine for every Unix scripts
#!/bin/sh
date=`date "+%Y-%m-%dT%H:%M:%S"`
rsync -aP --link-dest=$HOME/Backups/current /path/to/important_files $HOME/Backups/back-$date
rm -f $HOME/Backups/current
ln -s back-$date $HOME/Backups/current
#!/bin/sh
date=`date "+%Y-%m-%dT%H_%M_%S"`
rsync -azPE --link-dest=PATHTOBACKUP/current $SOURCE $HOST:PATHTOBACKUP/back-$date \
&& ssh $HOST "rm PATHTOBACKUP/current \
&& ln -s back-$date PATHTOBACKUP/current"
#!/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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment