Created
December 1, 2020 10:41
-
-
Save janglapuk/611ec767598fffbd1e6aaa6da50086ac to your computer and use it in GitHub Desktop.
Proxmox LXC container backup script to Google Drive using @prasmussen's gdrive
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 | |
if [ $# -ne 1 ]; | |
then | |
echo "Usage: $0 <VMID>" | |
exit 1 | |
fi | |
BACKUPDIR="/var/lib/vz/dump" | |
# --------------------------------------------------------------- | |
echo "" | |
VZDUMPLOG=$(vzdump $1 -compress lzo) | |
if [ $? -ne 0 ]; | |
then | |
echo "ERROR: some error occured on vzdump process. Exiting..." | |
exit 2 | |
fi | |
# --------------------------------------------------------------- | |
BACKUPFILE=$(echo "$VZDUMPLOG" | grep -o "creating archive .*" | grep -oEI "'.*'" | sed -e "s/'//g") | |
BASENAME=$(basename "$BACKUPFILE" ".tar.lzo") | |
LOGFILE="$BACKUPDIR/$BASENAME.log" | |
GDRIVEPARENT=$(cat /root/backup/parent_id.txt) | |
echo "Backup file : $BACKUPFILE" | |
echo "Log file : $LOGFILE" | |
echo "Drive parent : $GDRIVEPARENT" | |
/usr/local/bin/gdrive upload -p "$GDRIVEPARENT" "$BACKUPFILE" | |
/usr/local/bin/gdrive upload -p "$GDRIVEPARENT" "$LOGFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment