Created
March 16, 2022 11:18
-
-
Save ticapix/fdec7376db7555595d36840d22889549 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
SWIFTTOKEN=<token> | |
set -ex | |
tar -czf backup-www-`date +%F`.tar.gz $HOME/www | |
newestFile=`ls --time=ctime -1 backup-www*.tar.gz | head -n 1` | |
echo "New backup file $newestFile" | |
curl -i -T $newestFile -X PUT -H "X-Auth-Token: $SWIFTTOKEN" https://storage.sbg.cloud.ovh.net/v1/AUTH_008c2fc57c8f49e8bb8cbd61237bcb65/backup-members.gaia-x.eu/$newestFile | |
maxFile=14 | |
files="`ls --reverse --time=ctime -1 backup-www*.tar.gz`" | |
count=`echo "$files" | wc --line` | |
echo "There are $count backup files" | |
if [ $count -ge $maxFile ]; then | |
toDelete=`echo "$files" | head -n $((count - maxFile))` | |
rm --force $toDelete | |
else | |
echo "Nothing to do." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment