├── README.md
├── backup (OLD)
├── backup_recal.sh
└── backup_retro.sh
/README.md:
--------------------------------------------------------------------------------
1 | # RetroPie / RecalBox Simple Backup Script
2 | Hey guys!
3 |
4 | I make a simple shell script to backup all your RetroPie save files!
5 |
6 | [Get the latest version HERE!](https://github.com/BOBdotEXE/RetroPie-Simple-Backup-Script/releases/)
7 |
8 | **(Now with Cloud backups!)**
9 |
10 |
11 | ## Table of Contents:
12 |
13 | 1. [What can this script do?](#do)
14 | 2. [Getting started!](#start)
15 | 3. [Step 1: Getting the sync program *'Drive'*](#s1)
16 | 4. [Step 2: Setting up your backup folder](#s2)
17 | 5. [Step 3: Setting up Cloud sync](#s3)
18 | 6. [Step 4: Making the bakups not require user input (optinal)](#s4)
19 | 7. [Step 5: Running the backup script for the first time!](#s5)
20 | 8. [Step 6: Setting up Automatic Bakups](#s6)
21 | 9. [Step 7: (Optinal) Nigtly backups ](#nite)
22 | 10. [Configuring the script for custom settings](#conf)
23 |
24 |
25 | ## What can this script do?
26 |
27 | * It backs up all your saves to a folder that's on the default samba share, so you can easily transfer the dumps to your PC.
28 |
29 | * It timestamps all the backups down to the second!
30 |
31 | * Creates an md5 checksum to allow you to make sure noting happened to your backup during transfer (long story,don't ask..)
32 |
33 | * It's setup with FULL paths to your Roms and backups dir, so you can run the script from anywhere!
34 |
35 | * And it's configurable! Change a few vars, and you can customize the backup path, change the working (roms) directory, change the date format, etc.
36 |
37 | * You can set the backup dir to something like a dropbox/google drive sync
38 |
39 | Enjoy!
40 |
41 | **You can make it run at startup with too!**
42 |
43 |
44 |
45 | ## Getting Started!
46 |
47 | You can find the newist cloud enabled version [HERE!](https://github.com/BOBdotEXE/RetroPie-Simple-Backup-Script/releases/)
48 |
49 | You can place this script anywhere, but this guide will assume you put it in your home folder *(/home/pi/backup)*
50 |
51 | **PLEASE! DO NOT USE YOUR MAIN GOOGLE ACCOUNT FOR THIS!**
52 |
53 | **Only use an account that's you'd be okay with lousing all the data from, (just make a new google account)**
54 |
55 | *You can always set up a share to your main google account!* (safe)
56 |
57 | Ok, Ready? one, two, three, let's Jam!
58 |
59 |
60 |
61 | ## Step 1: Getting the sync program 'Drive'
62 |
63 | Download the [latest version of drive](https://github.com/BOBdotEXE/RetroPie-Simple-Backup-Script/releases/download/1.4/drive)
64 |
65 |
66 | [md5: 462e5b2ccf9ad4b98dde5c7cdaede17d]
67 |
68 | I compiled it from the source code, on my pi3, but it should at least work on the Pi2.
69 |
70 | You can find an older version [here](https://github.com/odeke-em/drive/releases/download/v0.2.2-arm-binary/drive-arm-binary), [Source](https://www.raspberrypi.org/forums/viewtopic.php?p=801697#p801697)
71 |
72 |
73 |
74 |
75 |
76 | ## Step 2: Setting up your backup folder
77 |
78 | If you have not yet, Pick a folder where you want your backups stored.
79 |
80 | I'll be using: */home/pi/Retropi/roms/backups*
81 |
82 | This is so I can easy copy the backups to my pc as needed, you can pick anywhere, but that's what I'll be using for this guide.
83 |
84 | ok, go ahead and copy the cloud enabled backup script from your zip file to your home directory. (/home/pi)
85 |
86 | then place *drive* in your backups folder, and make sure it's marked as executable (chmod +x)
87 |
88 |
89 |
90 | ## Step 3: Setting up Cloud sync
91 |
92 | And then go back to the backup script, and open it with your favorite text editor, and edit the 'backupDir' and replace the string "/home/pi/RetroPie/roms/backups" **If** you're using a different folder.
93 |
94 | Now open a terminal (or ssh) and navigate to your backups folder.
95 |
96 | Mark drive in as executable!
97 |
98 | chmod +x drive
99 |
100 | from there run:
101 |
102 | ./drive init /home/pi/RetroPie/roms/backups
103 |
104 | Replacing */home/pi/RetroPie/roms/backups* with your backup path,
105 |
106 |
107 | From here you'll be given a URL to visit, **Make sure you ONLY open that url when signed into your second/extra google account!!*
108 |
109 | That url will give you a code, copy and past that code back in the terminal where you ran *drive init*, then press enter.
110 |
111 | That should get your account all set up.
112 |
113 | Now Rename *drive* to *.drive* so it dose not get added to google drive :P
114 |
115 | mv drive .drive
116 |
117 |
118 | Once it's renamed to *.drive* it will be hidden, so if you can't see it, doesn't freak out!
119 |
120 |
121 |
122 |
123 | ## Step 4: Making the bakups not require user input (optinal)
124 |
125 | (optinal, but suggested!) so drive dose not always ask us to confirm each upload,
126 |
127 | create a new file called: *.driverc* (yes, with the '.' before the name) in the same folder as *'drive'*
128 |
129 | In side of it, you'll only need one line of text:
130 |
131 | no-prompt=true
132 |
133 | Then save, and close the file.
134 | And now google drive syncing should be all set!
135 |
136 |
137 |
138 | ## Step 5: Running the backup script for the first time!
139 |
140 | if you have not yet, mark the main script as executable.
141 |
142 | chmod +x ~/backup
143 |
144 | Next we'll need to install zip, so we can make compressed archives
145 |
146 | sudo apt-get install zip
147 |
148 | Now run the script!
149 |
150 | ~/backup
151 |
152 | And it should backup your files, and Automatically Sync them to google Drive!
153 |
154 |
155 |
156 | ## Step 6: Setting up Automatic Bakups
157 |
158 | **(Please Note, at this time automatic backup, are only backed up locally, but they will sync to the cloud at your next manual backup)**
159 |
160 | To make the system backup your saves everytime you boot
161 | Edit */etc/rc.local* and make a new line before exit, and type:
162 |
163 | runuser -l pi -c /home/pi/backup
164 |
165 | (change *'/home/pi/backup'* to the path of your script)
166 |
167 | and save the file!
168 |
169 | This will make it run every time you start up!
170 |
171 |
172 |
173 | ## Step 7: (Optinal) Nightly backups
174 |
175 | **If you also want to make nightly backups, you can do that too!**
176 |
177 | For nightly just before midnight, you'll edit your own cron jobs:
178 |
179 | crontab -e
180 | simply scroll to the bottom and add:
181 |
182 | 59 23 * * * /home/pi/backup
183 |
184 | You can add more if you want, just copy the line and change the times, like "59 11 * * *..." for noon backups, or
185 |
186 | and save the file!
187 |
188 |
189 |
190 | ## Configuring the script for custom settings
191 | This script should be pretty easy to undertsand, but I'll go over a few of the settings,
192 |
193 | First, open the script with any text editor, and we'll go over each main line that you can change.
194 |
195 | To change the folder where you save files are red from. (why???) just edit the *7th line*:
196 |
197 | (Make sure you **don't** put an extra **/** at the end)
198 |
199 | workingDir="/home/pi/RetroPie/roms"
200 |
201 | Simply change that to wherever your roms/saves are.
202 |
203 |
204 | To change where your backups are stored edit *line 9*:
205 |
206 | (Make sure you **don't** put an extra **/** at the end)
207 |
208 | backupDir="/home/pi/RetroPie/roms/backups"
209 |
210 |
211 | Next If you want to change the backup storage folder name, you can do that with *line 11*:
212 |
213 | *archiveFolderName="RetroPiSaves"*
214 |
215 | If you want to add a suffex to all the backup, for example if using 2 pi's you want to make one's backups end with "-MainPie", buy default, none are used. if you add one they will be called something like: *"15.04.02_03-29-2016-MainPie.zip"*
216 |
217 | backupSuffex=""
218 |
219 | If you *don't* live in the USA, and want all your backups to use the proper format: *Day-Month-Year
220 |
221 | Simply go down to lines *27-28*:
222 |
223 | #USA format
224 |
225 | timestamp="$(date +'%H.%M.%S_%m-%d-%Y')"
226 |
227 | #Proper format
228 |
229 | #timestamp="$(date +'%H.%M.%S_%d-%m-%Y')"
230 |
231 | And comment out *line 28*, and uncomment *line 30*, then it should look like this:
232 |
233 | #USA format
234 |
235 | #timestamp="$(date +'%H.%M.%S_%m-%d-%Y')"
236 |
237 | #Proper format
238 |
239 | timestamp="$(date +'%H.%M.%S_%d-%m-%Y')"
240 |
241 | With one-way sync (always upload, never download), Deleteing the files in google Drive **WILL NOT** remove them from the PI,
242 | (and any files deleted from the cloud will be re-uploaded next sync).
243 |
244 | To enable one way sync, go to *line 18*:
245 |
246 | ./.drive pull
247 |
248 | And change it to:
249 |
250 | #./.drive pull
251 |
252 |
253 | ---
254 |
255 | If you have any quesions for now, I guess you can ask them in the redit thread for this project:
256 | https://www.reddit.com/r/RetroPie/comments/4bdx0h/simple_configurable_script_to_back_up_all_save/
257 |
258 |
--------------------------------------------------------------------------------
/backup (OLD):
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #Simple backup script v1.5 (by BOBdotEXE)
3 | echo "Simple Backup script v 1.5 By BOBdotEXE"
4 | echo "github.com/BOBdotEXE/RetroPie-Simple-Backup-Script"
5 | echo " "
6 | #Directory where roms/saves are stored
7 | workingDir="/home/pi/RetroPie/roms"
8 | #Save bacup location
9 | backupDir="/home/pi/RetroPie/roms/backups"
10 | #Name for the root backups folder (will be placed INSIDE of your 'backup location'
11 | archiveFolderName="RetroPiSaves"
12 | #Suffex to append to the end of all backups (example: "-backups") NO SPACES ALLOWED! (Don't use "MY BACK UPS"!!!)
13 | backupSuffex=""
14 | #backup dir may be relitive.
15 | cd $backupDir
16 | echo Syncing changes..
17 | #comment out for oneway sync vvv
18 | $workingDir/.drive pull
19 | echo " "
20 | echo Creating Save File backup now!
21 | echo " "
22 | cd $workingDir
23 | #Get date varibles for folders
24 | Y=$(date +'%Y')
25 | M=$(date +'%m-%b')
26 | D=$(date +'%d')
27 | #USA format
28 | timestamp="$(date +'%H.%M.%S_%m-%d-%Y')"
29 | #Proper format
30 | #timestamp="$(date +'%H.%M.%S_%d-%m-%Y')"
31 | [ -d $backupDir ] || mkdir $backupDir
32 | [ -d $backupDir/$archiveFolderName ] || mkdir $backupDir/$archiveFolderName
33 | [ -d $backupDir/$archiveFolderName/$Y ] || mkdir $backupDir/$archiveFolderName/$Y
34 | [ -d $backupDir/$archiveFolderName/$Y/$M ] || mkdir $backupDir/$archiveFolderName/$Y/$M
35 | [ -d $backupDir/$archiveFolderName/$Y/$M/$D ] || mkdir $backupDir/$archiveFolderName/$Y/$M/$D
36 | find . | egrep "\.(sav|srm)$" | zip -@ $backupDir/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.zip
37 | md5=($(md5sum "$backupDir"/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.zip))
38 | echo $md5 >> "$backupDir"/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.md5
39 | echo " "
40 | echo "Backup Completed!"
41 | echo "Saved to $(date +'%m-%d-%Y_%H.%M.%S').zip"
42 | echo "And md5 created for verification!"
43 | echo " "
44 | echo "Uploading to Google Drive..."
45 | cd $backupDir
46 | $workingDir/.drive push
47 | echo " "
48 | echo Complete!
49 |
--------------------------------------------------------------------------------
/backup_recal.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #Simple backup script v1.51 (by BOBdotEXE)
3 | echo "Simple Backup script v 1.51 (beta) By BOBdotEXE"
4 | echo "github.com/BOBdotEXE/RetroPie-Simple-Backup-Script"
5 | echo " "
6 | #Directory where roms/saves are stored
7 | workingDir="/recalbox/share/roms/"
8 | #Save bacup location
9 | backupDir="/recalbox/share/roms/backups"
10 | #Name for the root backups folder (will be placed INSIDE of your 'backup location'
11 | archiveFolderName="RecalBoxSaves"
12 | #Suffex to append to the end of all backups (example: "-backups") NO SPACES ALLOWED! (Don't use "MY BACK UPS"!!!)
13 | backupSuffex=""
14 | #backup dir may be relitive.
15 | cd $backupDir
16 | echo Syncing changes..
17 | #comment out for oneway sync vvv
18 | $workingDir/.drive pull
19 | echo " "
20 | echo Creating Save File backup now!
21 | echo " "
22 | cd $workingDir
23 | #Get date varibles for folders
24 | Y=$(date +'%Y')
25 | M=$(date +'%m-%b')
26 | D=$(date +'%d')
27 | #USA format
28 | timestamp="$(date +'%H.%M.%S_%m-%d-%Y')"
29 | #Proper format
30 | #timestamp="$(date +'%H.%M.%S_%d-%m-%Y')"
31 | [ -d $backupDir ] || mkdir $backupDir
32 | [ -d $backupDir/$archiveFolderName ] || mkdir $backupDir/$archiveFolderName
33 | [ -d $backupDir/$archiveFolderName/$Y ] || mkdir $backupDir/$archiveFolderName/$Y
34 | [ -d $backupDir/$archiveFolderName/$Y/$M ] || mkdir $backupDir/$archiveFolderName/$Y/$M
35 | [ -d $backupDir/$archiveFolderName/$Y/$M/$D ] || mkdir $backupDir/$archiveFolderName/$Y/$M/$D
36 | find . | egrep "\.(sav|srm)$" | zip -@ $backupDir/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.zip
37 | md5=($(md5sum "$backupDir"/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.zip))
38 | echo $md5 >> "$backupDir"/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.md5
39 | echo " "
40 | echo "Backup Completed!"
41 | echo "Saved to $(date +'%m-%d-%Y_%H.%M.%S').zip"
42 | echo "And md5 created for verification!"
43 | echo " "
44 | echo "Uploading to Google Drive..."
45 | cd $backupDir
46 | $workingDir/.drive push
47 | echo " "
48 | echo Complete!
49 |
--------------------------------------------------------------------------------
/backup_retro.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #Simple backup script v1.51 (by BOBdotEXE)
3 | echo "Simple Backup script v 1.51 By BOBdotEXE"
4 | echo "github.com/BOBdotEXE/RetroPie-Simple-Backup-Script"
5 | echo " "
6 | #Directory where roms/saves are stored
7 | workingDir="/home/pi/RetroPie/roms/"
8 | #Save bacup location
9 | backupDir="/home/pi/RetroPie/roms/backups"
10 | #Name for the root backups folder (will be placed INSIDE of your 'backup location'
11 | archiveFolderName="RetroPiSaves"
12 | #Suffex to append to the end of all backups (example: "-backups") NO SPACES ALLOWED! (Don't use "MY BACK UPS"!!!)
13 | backupSuffex=""
14 | #backup dir may be relitive.
15 | cd $backupDir
16 | echo Syncing changes..
17 | #comment out for oneway sync vvv
18 | $workingDir/.drive pull
19 | echo " "
20 | echo Creating Save File backup now!
21 | echo " "
22 | cd $workingDir
23 | #Get date varibles for folders
24 | Y=$(date +'%Y')
25 | M=$(date +'%m-%b')
26 | D=$(date +'%d')
27 | #USA format
28 | timestamp="$(date +'%H.%M.%S_%m-%d-%Y')"
29 | #Proper format
30 | #timestamp="$(date +'%H.%M.%S_%d-%m-%Y')"
31 | [ -d $backupDir ] || mkdir $backupDir
32 | [ -d $backupDir/$archiveFolderName ] || mkdir $backupDir/$archiveFolderName
33 | [ -d $backupDir/$archiveFolderName/$Y ] || mkdir $backupDir/$archiveFolderName/$Y
34 | [ -d $backupDir/$archiveFolderName/$Y/$M ] || mkdir $backupDir/$archiveFolderName/$Y/$M
35 | [ -d $backupDir/$archiveFolderName/$Y/$M/$D ] || mkdir $backupDir/$archiveFolderName/$Y/$M/$D
36 | find . | egrep "\.(sav|srm)$" | zip -@ $backupDir/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.zip
37 | md5=($(md5sum "$backupDir"/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.zip))
38 | echo $md5 >> "$backupDir"/"$archiveFolderName"/$Y/$M/$D/"$timestamp"$backupSuffex.md5
39 | echo " "
40 | echo "Backup Completed!"
41 | echo "Saved to $(date +'%m-%d-%Y_%H.%M.%S').zip"
42 | echo "And md5 created for verification!"
43 | echo " "
44 | echo "Uploading to Google Drive..."
45 | cd $backupDir
46 | $workingDir/.drive push
47 | echo " "
48 | echo Complete!
--------------------------------------------------------------------------------