forked from BOBdotEXE/RetroPie-Simple-Backup-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup
54 lines (54 loc) · 2.03 KB
/
backup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#Simple backup script v1.5 (by BOBdotEXE)
echo "Simple Backup script v 1.5 By BOBdotEXE"
echo "github.com/BOBdotEXE/RetroPie-Simple-Backup-Script"
echo " "
#Directory where roms/saves are stored
workingDir="/home/pi/RetroPie/roms/"
#Directory where drive program is located.
driveDir="/home/pi"
#Save bacup location
backupDir="/home/pi"
#Name for the root backups folder (will be placed INSIDE of your 'backup location'
archiveFolderName="RetroPieSaves"
#Suffex to append to the end of all backups (example: "-backups") NO SPACES ALLOWED! (Don't use "MY BACK UPS"!!!)
backupSuffex=""
#backup dir may be relitive.
cd $backupDir
echo Syncing changes..
#comment out for oneway sync vvv
#/home/pi/.drive pull
echo " "
echo Creating Save File backup now!
echo " "
cd $workingDir
#Get date varibles for folders
Y=$(date +'%Y')
M=$(date +'%m')
D=$(date +'%d')
#Mike Format
timestamp="$(date +'%Y-%m-%d_%H.%M.%S')"
#USA format
#timestamp="$(date +'%H.%M.%S_%m-%d-%Y')"
#Proper format
#timestamp="$(date +'%H.%M.%S_%d-%m-%Y')"
[ -d $backupDir ] || mkdir $backupDir
[ -d $backupDir/$archiveFolderName ] || mkdir $backupDir/$archiveFolderName
[ -d $backupDir/$archiveFolderName/$Y ] || mkdir $backupDir/$archiveFolderName/$Y
[ -d $backupDir/$archiveFolderName/$Y/$M ] || mkdir $backupDir/$archiveFolderName/$Y/$M
[ -d $backupDir/$archiveFolderName/$Y/$M/$D ] || mkdir $backupDir/$archiveFolderName/$Y/$M/$D
rm $backupDir/$archiveFolderName/$Y/$M/$D/*.zip
rm $backupDir/$archiveFolderName/$Y/$M/$D/*.md5
find . | egrep "\.(sav|srm|fs|nv|cfg|state.*)$" | zip -@ $backupDir/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.zip
md5=($(md5sum "$backupDir"/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.zip))
echo $md5 >> "$backupDir"/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.md5
echo " "
echo "Backup Completed!"
echo "Saved to $(date +'%Y-%m-%d_%H.%M.%S').zip"
echo "And md5 created for verification!"
echo " "
echo "Uploading to Google Drive..."
cd $backupDir/$archiveFolderName
$driveDir/drive push -quiet -fix-clashes
echo " "
echo Complete!