Skip to content

Instantly share code, notes, and snippets.

@Stuyk
Created July 19, 2022 00:19
Show Gist options
  • Save Stuyk/d364a3eb525b9a910dd06a1bda8e6188 to your computer and use it in GitHub Desktop.
Save Stuyk/d364a3eb525b9a910dd06a1bda8e6188 to your computer and use it in GitHub Desktop.
Minecraft Backup Script with ./gdrive
# Run These In Order...
wget https://github.com/prasmussen/gdrive/releases/download/2.1.1/gdrive_2.1.1_linux_386.tar.gz
tar -xvf gdrive_2.1.1_linux_386.tar.gz
chmod +x ./gdrive
./gdrive about
#!/bin/bash
echo "Performing Backup..."
BACKUP_FOLDER="/home/minecraft/backup"
SERVER_FILES="/home/minecraft/server-files"
FILE_NAME=$(date +"%Y_%m_%d_%I_%M_%p").tar.gz
G_DRIVE_FOLDER="g-drive-folder-id-to-backup-to"
declare -a FOLDERS_TO_BACKUP=( "better-minecraft-modpack-new-11-5" )
rm -rf $BACKUP_FOLDER
mkdir $BACKUP_FOLDER
echo "Copying Specified Folders for Backup"
for FOLDER in ${FOLDERS_TO_BACKUP[@]}; do
echo "Backing Up $FOLDER"
cp -R $SERVER_FILES/$FOLDER $BACKUP_FOLDER/$FOLDER
done
echo "Copying World Folders"
for DIRECTORY in "$SERVER_FILES/world"*/
do
DIRECTORY_NAME=$(basename $DIRECTORY)
echo "Backing Up $DIRECTORY_NAME"
cp -R $DIRECTORY $BACKUP_FOLDER/$DIRECTORY_NAME
done
echo "Creating tar.gz"
tar cvf - $BACKUP_FOLDER | gzip -9 - > $FILE_NAME
echo "Uploading..."
./gdrive upload --parent $G_DRIVE_FOLDER ./$FILE_NAME
rm $FILE_NAME
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment