0

I'm trying to back up my retro pie SD card in case of corruption, but Retro pie does not have a desktop environment, so can't use the sd card copier tool. Is there some terminal command to do this? I'm using a raspberry pi4 and the official retro pie image.

2
  • 1
    I could use a little more clarification for these answers.
    – UNKNOWN
    Jun 18 '20 at 20:28
  • I agree on the "more clarification needed" point. I don't know what "retro pi" is (another clever marketing gimmick from the House of Pi?), BUT you might consider image-utils as a potential solution. I've posted several answers here that proposed image-utils as a backup solution - this one in response to a long-standing question that has other solutions you may find useful.
    – Seamus
    Jul 6 at 19:42
3

You can use dd, this applies also for creating an image of an SDD, USB, ... and restoring it

It's best to unmount the drive you're going to copy. In case of the SD-card, remove the SD-card from the RPi and put it into a card reader. Don't mount.

The basic command is this:

dd if=input_file of=output_file status=progress

Use lsblk to determine the name of the drive, eg. /dev/sdb

So if your SD-card/USB/SDD is on /dev/sdb:

sudo dd if=/dev/sdb of=/path/to/folder/backup.img status=progress

to restore

sudo dd if=/path/to/folder/backup.img of=/dev/sdb status=progress

Don't output the file onto the same SD card. Use another drive. You can use the block size BS to use bigger blocks. Eg. BS=4M

If you want, you can pipe the image directly into a compressed file. Eg. using gzip

sudo dd if=/dev/sdb | gzip > /path/to/folder/backup.img.gz

To restore:

gunzip -c /path/to/folder/backup.img.gz | sudo dd of=/dev/sdb status=progress

Taken from the question over at unix.stackexchange. To backup from your computer over ssh without removing the SD-card

ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz
10
  • As far as I understand the OP like to backup the running system itself. This isn't possible with dd.
    – Ingo
    Jun 18 '20 at 8:27
  • @Ingo It's an SD card he wants to back up. Put it into a card reader, et viola
    – Swedgin
    Jun 18 '20 at 8:33
  • @Swedgin Have you tested this?
    – UNKNOWN
    Jun 18 '20 at 12:01
  • @UNKNOWN yes, this is a known command in linux (man7.org/linux/man-pages/man1/dd.1.html).
    – Swedgin
    Jun 19 '20 at 7:32
  • @Swedgin Is "/dev/sda" The location of my raspberry pi's SD card?
    – UNKNOWN
    Jun 19 '20 at 17:38
2

Have a look through Using rsync to backup Pi

You need to set the exclusions to include where the roms are stored.

I would question why not backup the rom files though? Restoring the machine WHEN (not if) the SD card fails will take significantly longer if you have to download / find all the rom files again...

0

I don't think there is on command in either Linux or the RetroPi setup to achieve this but you can use either :

https://github.com/crcerror/RetroPie-Simple-Backup-Script

OR

https://github.com/kallsbo/BASH-RaspberryPI-System-Backup

There may be other scripts or options available if you do a web search. In Linux at least Bash scripts are your friends :D

1
  • @ Etescartz Sorry, but I want to copy the SD card not the roms.
    – UNKNOWN
    Jun 17 '20 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.