Backup SD Card by copying out files?
-
@herb_fargus i might give it a go...i am thinking that i install the my base image and make it bootable. Once it is up and running, i go into the file structure and replace files that have been modified, like the retroarch, emulationstation, and other config folders and files for the roms and controller settings.
-
Has anyone tried to backup all of their files by simply copying all of the folders off of the SD card onto their hard drive and then installing a fresh image of retropie and copying all of the files back onto the new installation?
I've done this several times now without any issue. I wrote a script that runs every night and makes a backup of the necessary files to a thumbdrive and only keeps the two most recent backups. I prefer to do it this way for space reasons, as well as knowing that I can more easily move up to a new Raspbian whenever the time comes.
-
@mediamogul Sweet! I thought it might work. Do you by chance have a list of files/folders that you backup that you could send my way?
-
Sure. For me, those files and folders include:
/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/.q3aEdit: My
/home/pi/Retropie
folder is already external, so it's not included. -
@mediamogul said in Backup SD Card by copying out files?:
Has anyone tried to backup all of their files by simply copying all of the folders off of the SD card onto their hard drive and then installing a fresh image of retropie and copying all of the files back onto the new installation?
I've done this several times now without any issue. I wrote a script that runs every night and makes a backup of the necessary files to a thumbdrive and only keeps the two most recent backups. I prefer to do it this way for space reasons, as well as knowing that I can more easily move up to a new Raspbian whenever the time comes.
Could you post your script, this would help a lot of people who don't want to lose all the effort they put it to get RetroPie running how they want it to in case of SD Card corruption or otherwise and add backup support
Thanks
-
@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.
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.