Last active
November 26, 2019 01:42
-
-
Save Maxopoly/42604f662d7b0748e11ba56da004a158 to your computer and use it in GitHub Desktop.
Backup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Adjust to your personal needs and schedule on a cronjob running every minute by running "crontab -e" | |
#and adding "* * * * * bash /home/max/scr/backup.sh". Obviously adjust the path as needed | |
cryptFolder=/home/max/crypt/vault/ | |
#Highly recommend using a private repo here to avoid meta data extraction by third parties | |
[email protected]:Maxopoly/files.git | |
branch=master | |
#Adjust client name for each client so you can distinguish in the commit history who made a change | |
clientName=desktop | |
#mkdir is atomic, which we use here to ensure two instances of the script dont run at the same time | |
mutexDir=/tmp/backupcrypt.lock | |
if mkdir "$mutexDir" | |
then | |
cd $cryptFolder | |
git checkout master | |
git fetch $remote master:temp | |
git rebase temp | |
git branch -d temp | |
git add . | |
git commit -m "$clientName" | |
git push $remote master:master | |
rm -rf "$mutexDir" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment