Backup SD Card by copying out files?
-
@steptoe said in Backup SD Card by copying out files?:
Could you post your script
Can do:
#!/bin/sh ##Change the numeral in "head -n -*" to however many backups are to be kept. foldername=$(date +%Y%m%d%H%M%S) && \ mkdir -p /media/usb0/Backups/RetroPie/"$foldername" && \ sudo cp -rfv \ /boot/config.txt \ /etc/fstab \ /etc/udev/rules.d \ /etc/rc.local \ /etc/samba/smb.conf \ /opt/retropie/configs \ /home/pi/.config \ /home/pi/.local \ /home/pi/.openMSX \ /home/pi/.q3a \ /media/usb0/Backups/RetroPie/"$foldername"/ cd /media/usb0/Backups/RetroPie/ && \ ls -1tr | head -n -2 | xargs -d '\n' rm -rfv -- clear
-
@mediamogul this is great! Is this script just a one time copy that I can run every time I want to make a copy? Also, is is possible to change the location form the USB to a location over the network? Or do I need to make the copy to a USB? Thanks for this! It will be very useful!
-
is this script just a one time copy that I can run every time I want to make a copy?
I run it in two different ways. First, the actual script resides in
/home/pi/RetroPie/retropiemenu
. That way, I can navigate to the RetroPie menu in Emulation Station and launch it manually whenever I want. Secondly, I have it set as a scheduled Cron task that launches every morning at 4:00am automatically.Also, is is possible to change the location form the USB to a location over the network?
Sure. If you have any network shares mounted at boot, you can just point the script in their direction.
-
@mediamogul probably a dumb question but I am on my phone so I can't test the script right now, but in the last line above clear in you script post the 'n' shows up in green like the "filename" which is Kent to be user modified. Is the 'n' supposed to be modified or is that green just because the forum post sees the ' on either side.
Thanks, this is really cool!
-
or is that green just because the forum post sees the ' on either side.
It's just the forum post.
-
I personally backup the entire /opt/retropie/ folder. So if i get an emulator that no longer works, i can put the old one on. Example: the new lr-mame2010 no longer works at all. So i have to put the old one on.
-
Very wise. I've thought about doing the same.
-
@mediamogul i actually backup files as i add/change stuff. Then i do a backup of all my selected files and folders everytime i do a retropie update. I have about 10-15 major backups.
-
Wow. If luck favors the prepared, I should be asking you for lottery numbers.
-
@mediamogul I just deleted my 2.6 backup a couple months ago. Still have all my updates after that
-
For backing up without doing a full image backup, I'd recommend looking up the rpi-clone script, provided you can plug the destination card via USB to your Pi.
-
@pjft Thanks for the info, i looked into that but it looks like i would have to have another 128gb SD card to make that work. I have a good base image for my system already saved on my computer, so my thought is that I can just copy off the folders with updates like @mediamogul has provided and then dump those back into the build once I reinstall my base image on the SD Card.
@mediamogul, i am a little green when it comes to installing scripts, i was just going to run it from putty, but i like the idea of having the script right on the retropie menu. Forgive me for this beginner question, but do i just save the script code you posted in a .xml and then save that file to /home/pi/RetroPie/retropiemenu? That seems to easy.......Thanks
-
but do i just save the script code you posted in a .xml and then save that file to /home/pi/RetroPie/retropiemenu? That seems to easy.......Thanks
It's just about that easy. Save it with the extension
.sh
and then run:chmod +x /home/pi/RetroPie/retropiemenu/name-of-script.sh
After that it should be good to go.
-
@mediamogul Awesome, you are the best and made my day!
-
@TMNTturtlguy you'd need a second card, but not the same size (unless your ROMS are there). But yeah, the other folders are the key ones.
-
@pjft unfortunately my roms are on my SD card. I started my builds before i joined this community and read all the documents and made my first build on a 128GB and it worked great, so I made an image and started make base copies for each of my additional builds (stand up arcade machines as well as a plug and play TV setup). All of my roms are set up with the correct emulators and have game cores set and they are all scraped to the location on the SD Card. I would love to simply move the roms off the card so if and when the SD card corrupts I don't have to replace it with a 128gb, but I believe that would take a lot of effort? Right now i have all my builds with the same base so I hope this will allow me to create a backup of the mods i make for each setup. Reinstall the base image and overwrite the folders in the base with the USB backup. Downside is i have to replace a 128 SD card instead of an 8 gb card.
-
I would love to simply move the roms off the card so if and when the SD card corrupts I don't have to replace it with a 128gb, but I believe that would take a lot of effort?
There's a very easy way to move the entire RetroPie folder externally that was introduced a few month's back.
-
@mediamogul would i need to repath all of my gamelists?
-
No, the beauty part is that because the new location is mounted over the old, the entire system never knows there was a change.
-
@mediamogul WOW - that is awesome....ok, so now a few more question as I am trying to compute all of this info - Thanks again as i am learning a lot today!
-
I am currently running 128gb cards, lets say i get 128 gb usb stick and copy over the roms. Now i am left with a 128gb card running with no roms on it. Could I use your script to copy over the important files, move the roms over, get a new 8gb card and throw a clean retropie image onto it, copy the folders i pulled off onto the clean image on the 8gb card and continue to run as if nothing changed? I guess to simplify, can i copy the roms and folders and build an 8gb card that will run identical to my current 128 SD card build?
-
The instructions have you turn on the USB transfer service, they don't say to turn it off after the transfer? Do you just leave it on at all times?
-
after i transfer the roms and it is mounted, can i then take the USB out and plug it back into my windows computer to add roms, or is it best to still add roms over WinSCP?
-
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.