The default script works great. I suggest everyone use that, and customize how they want. I made a few changes that might be important to some people.
- File extensions .sav, .srm, .fs, .cfg, and .state are all saved from the roms directory. Only .sav and .srm are saved in the default script. These other file extensions are for additional systems, and MAME/NEOGEO game configurations you might setup. The .state extensions is important for anyone using save states.
- I changed the folder names. The 1.4 script had "July" I changed it it to "07". The default for the 1.5 script now does "07-July", but I felt month name wasn't necessary.
- Filenames follow the same convetion as the directories, with the largest to smallest amount of time: Year - Month - Day - Hour - Minute - Second. Default script has filenames as: Hour - Minute - Second - Month - Day - Year. My naming works better for sorting if you put them all in one folder.
- I have my script run every hour at the 59 minute mark. To keep from having 24 archives a day, the script removes all previous archives generated that day. Only the last archive made is kept for each day. This helps save space on the SD card and save very minimal space on Google Drive. My archive is around 10 megabytes. This does not prevent it from uploading 24 archives, it just prevents it from storing each of those iterations permanently.
- I created another variable for the location of drive. I personally don't like it in the roms folder.
- I commented out the pull. This might conflict with the commands to remove previous archives. I don't need to pull, I only plan to restore from the latest archive if the SD card fails. This is completely up to user preference though.
- Added ARMv7 drive executable. Release v0.3.8 (HiatusReturnIsAComingOfAge) 2016/09/28. https://github.com/odeke-em/drive/releases
Hey guys!
I make a simple shell script to backup all your RetroPie save files!
(Now with Cloud backups!)
- What can this script do?
- Getting started!
- Step 1: Getting the sync program 'Drive'
- Step 2: Setting up your backup folder
- Step 3: Setting up Cloud sync
- Step 4: Making the bakups not require user input (optinal)
- Step 5: Running the backup script for the first time!
- Step 6: Setting up Automatic Bakups
- Step 7: (Optinal) Nigtly backups
- Configuring the script for custom settings
-
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.
-
It timestamps all the backups down to the second!
-
Creates an md5 checksum to allow you to make sure noting happened to your backup during transfer (long story,don't ask..)
-
It's setup with FULL paths to your Roms and backups dir, so you can run the script from anywhere!
-
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.
-
You can set the backup dir to something like a dropbox/google drive sync
Enjoy!
You can make it run at startup with too!
You can find the new cloud enabled version HERE!
You can place this script anywhere, but this guide will assume you put it in your home folder (/home/pi/backup)
PLEASE! DO NOT USE YOUR MAIN GOOGLE ACCOUNT FOR THIS!
Only use an account that's you'd be okay with lousing all the data from, (just make a new google account)
You can always set up a share to your main google account! (safe)
Ok, Ready? one, two, three, let's Jam!
Download the latest version of drive
[md5: 462e5b2ccf9ad4b98dde5c7cdaede17d]
I compiled it from the source code, on my pi3, but it should at least work on the Pi2.
You can find an older version here, Source
If you have not yet, Pick a folder where you want your backups stored.
I'll be using: /home/pi/Retropi/roms/backups
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.
ok, go ahead and copy the cloud enabled backup script from your zip file to your home directory. (/home/pi)
then place drive in your backups folder, and make sure it's marked as executable (chmod +x)
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.
Now open a terminal (or ssh) and navigate to your backups folder.
Mark drive in as executable!
chmod +x drive
from there run:
drive init /home/pi/RetroPie/roms/backups
Replacing /home/pi/RetroPie/roms/backups with your backup path,
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!!
That url will give you a code, copy and past that code back in the terminal where you ran drive init, then press enter.
That should get your account all set up.
Now Rename drive to .drive so it dose not get added to google drive :P
mv drive .drive
Once it's renamed to .drive it will be hidden, so if you can't see it, don't freak out!
(optinal, but suggested!) so drive dose not always ask us to confirm each upload,
create a new file called: .driverc (yes, with the '.' before the name) in the same folder as 'drive'
In side of it, you'll only need one line of text:
no-prompt=true
Then save, and close the file. And now google drive syncing should be all set!
if you have not yet, mark the main script as executable.
chmod +x ~/backup
Next we'll need to install zip, so we can make compressed archives
sudo apt-get install zip
Now run the script!
~/backup
And it should backup your files, and Automatically Sync them to google Drive!
(Please Note, at this time automatic backup, are only backed up locally, but they will sync to the cloud at your next manual backup)
To make the system backup your saves everytime you boot Edit /etc/rc.local and make a new line before exit, and type:
runuser -l pi -c /home/pi/backup
(change '/home/pi/backup' to the path of your script)
and save the file!
This will make it run every time you start up!
If you also want to make nightly backups, you can do that too!
For nightly just before midnight, you'll edit your own cron jobs:
crontab -e
simply scroll to the bottom and add:
59 23 * * * /home/pi/backup
You can add more if you want, just copy the line and change the times, like "59 11 * * *..." for noon backups, or
and save the file!
This script should be pretty easy to undertsand, but I'll go over a few of the settings,
First, open the script with any text editor, and we'll go over each main line that you can change.
To change the folder where you save files are red from. (why???) just edit the 7th line:
*workingDir="/home/pi/RetroPie/roms/"*
Simply change that to wherever your roms/saves are.
To change where your backups are stored edit line 9:
*backupDir="/home/pi/RetroPie/roms/backups"*
Next If you want to change the backup storage folder name, you can do that with line 11:
*archiveFolderName="RetroPiSaves"*
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"
backupSuffex=""
If you don't live in the USA, and want all your backups to use the proper format: *Day-Month-Year
Simply go down to lines 27-28:
#USA format
timestamp="$(date +'%H.%M.%S_%m-%d-%Y')"
#Proper format
#timestamp="$(date +'%H.%M.%S_%d-%m-%Y')"
And comment out line 28, and uncomment line 30, then it should look like this:
#USA format
#timestamp="$(date +'%H.%M.%S_%m-%d-%Y')"
#Proper format
timestamp="$(date +'%H.%M.%S_%d-%m-%Y')"
With one-way sync (always upload, never download), Deleteing the files in google Drive WILL NOT remove them from the PI, (and any files deleted from the cloud will be re-uploaded next sync).
To enable one way sync, go to line 18:
./.drive pull
And change it to:
#./.drive pull
If you have any quesions for now, I guess you can ask them in the redit thread for this project: https://www.reddit.com/r/RetroPie/comments/4bdx0h/simple_configurable_script_to_back_up_all_save/