Last active
September 25, 2018 01:26
-
-
Save erikdemarco/959e3afc29122634631e59d3e3640333 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/bash | |
#Save current date as YYYY-MM-DD to a variable | |
DATE=$(date +"%Y-%m-%d") | |
BACKUP_FOLDER="/home/backup/" | |
#Loop through each file in the backup folder whose name has the current date | |
for X in "$BACKUP_FOLDER"*$DATE*; do | |
#if file not found dont continue | |
if [ ! -e $X ] | |
then | |
exit | |
fi | |
#X is the filename with path. Remove path to get just the filename. | |
NAME_NO_PATH=${X##*/} | |
#Remove the date from the name (removes all text between the periods) | |
NEW_NAME="${NAME_NO_PATH%%.*}.${NAME_NO_PATH##*.}" | |
#get username | |
USER_NAME="${NAME_NO_PATH%%.*}" | |
#Copy the file to tmp with the new non-dated name | |
cp $X "$BACKUP_FOLDER$NEW_NAME" | |
#Send it to Dropbox (using downloaded api dropbox_uploader.sh) | |
/dropbox/dropbox_uploader.sh -f /root/.dropbox_uploader upload "$BACKUP_FOLDER$NEW_NAME" / | |
#delete uploaded data | |
rm -rf "$BACKUP_FOLDER$NEW_NAME" | |
#fixing the problem that will exist | |
export VESTA=/usr/local/vesta/ | |
#Delete the backup using api (so the counter is updated in panel) | |
sudo /usr/local/vesta/bin/v-delete-user-backup $USER_NAME $NAME_NO_PATH | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment