Page 1 of 1

How to backup SD card

Posted: Sun Sep 05, 2021 10:38 am
by Robgus
I feel a bit silly for asking this, but here goes…

To backup my sd card, is just simply copy all folders and files to my computer? Or do I need to clone it - let’s say I want to put the same content on another card?

Thanks!

Re: How to backup SD card

Posted: Sun Sep 05, 2021 10:43 am
by cursedverses
You have a couple of ways, pick the one that suits your use case.

If you wanted to clone the SD card, I believe Balena's Etcher can now make full disk images of SD cards. You'd probably only want to do this to the same size SD card though as I'm unsure if partition resizing tools are on the Linux install.

Otherwise, you could copy the contents of the filesystem somewhere else, but you would have to flash the MiSTer system to your fresh SD card before copying the files back - there are a few partitions that will be hidden from you.

I think that should cover you. I'd personally go for the second option as I'm likely to go for a larger SD card in the future (for example, if/when PSX hits the scene)

Re: How to backup SD card

Posted: Sun Sep 05, 2021 11:57 am
by Robgus
Cheers! Option two sounds good.

I have copied all folders and files to my computer already so I guess I’m somewhat covered if anything happens.

All the best

Re: How to backup SD card

Posted: Sun Sep 05, 2021 5:24 pm
by Blitzwing
Robgus wrote: Sun Sep 05, 2021 10:38 am I feel a bit silly for asking this, but here goes…

To backup my sd card, is just simply copy all folders and files to my computer? Or do I need to clone it - let’s say I want to put the same content on another card?

Thanks!
If you're running Linux on your PC you can use Rsync, that's how I've started to do mine as it'll only update changes and it just goes straight to my NAS. Set up a cronjob and as long as the MiSTer is on then you won't even need to think about backups.

Not overly necessary I guess with MiSTer if you don't change too much from one day to the next, but it's another option.

Re: How to backup SD card

Posted: Sun Sep 05, 2021 11:19 pm
by zorrobandito
Blitzwing wrote: Sun Sep 05, 2021 5:24 pm
If you're running Linux on your PC you can use Rsync, that's how I've started to do mine as it'll only update changes and it just goes straight to my NAS. Set up a cronjob and as long as the MiSTer is on then you won't even need to think about backups.
This is a great idea! Since MISTer runs Linux, is this something that could be configured directly on it, instead of proxying the task to a desktop Linux (which I don't have)?

Re: How to backup SD card

Posted: Mon Sep 06, 2021 1:28 am
by darksakul
The Linux on the MiSTer SD card is really stripped down. You have to do it from the command shell.
And I never tried to see if that worked.

Re: How to backup SD card

Posted: Mon Sep 06, 2021 2:52 am
by Blitzwing
zorrobandito wrote: Sun Sep 05, 2021 11:19 pm
Blitzwing wrote: Sun Sep 05, 2021 5:24 pm
If you're running Linux on your PC you can use Rsync, that's how I've started to do mine as it'll only update changes and it just goes straight to my NAS. Set up a cronjob and as long as the MiSTer is on then you won't even need to think about backups.
This is a great idea! Since MISTer runs Linux, is this something that could be configured directly on it, instead of proxying the task to a desktop Linux (which I don't have)?
I said in my previous post that it be could set as a cronjob, which is the Linux utility that automates commands at specified dates and times. However I was getting a little ahead of myself there as whilst I've sorted the commands for Rsync that I needed for both the SD card and USB storage I haven't actually looked to see if Cron is even in MiSTer Linux, as dark said Sorg strips out a lot of stuff to keep Linux as light as possible.

If not then it'd have to be ran when wanted, you can do that from Windows using a program like Putty.

I'll report back when I get a chance to test.

Re: How to backup SD card

Posted: Mon Sep 06, 2021 6:10 am
by Pepeart
I have a backup image that I created using win32 diskimager.

Re: How to backup SD card

Posted: Fri Sep 20, 2024 7:20 am
by INT806

A friend was kind enough to burn a copy of his entire "MISTer_Data" micro SD card (his card is only 512GB) on my 1000GB (1TB) Micro SD card. He did not install a fresh MISTer system on my card first (with Mr. Fusion), so now only his 512GB partition is on my 1000GB card (and 512GB are currently unused/wasted). I would of course like to have the whole 1000GB so my question is: is it enough if I copy all the files from this card to my HDD, then use Mr. Fusion to create a whole new MISTer system on it (this time with 1TB) and then simply copy all the files form my HDD back on the micro SD card? I think in theory, this should work, right? Or am I missing something important here? Would I 'miss' some files or hidden partitions?


Re: How to backup SD card

Posted: Fri Sep 20, 2024 5:39 pm
by Waifu4Life

Personally, I backup everything but the Linux folder, I'll just let MiSTer Fusion remake it.


Re: How to backup SD card

Posted: Sat Sep 21, 2024 5:00 am
by pgimeno
INT806 wrote: Fri Sep 20, 2024 7:20 am

A friend was kind enough to burn a copy of his entire "MISTer_Data" micro SD card (his card is only 512GB) on my 1000GB (1TB) Micro SD card. He did not install a fresh MISTer system on my card first (with Mr. Fusion), so now only his 512GB partition is on my 1000GB card (and 512GB are currently unused/wasted). I would of course like to have the whole 1000GB so my question is: is it enough if I copy all the files from this card to my HDD, then use Mr. Fusion to create a whole new MISTer system on it (this time with 1TB) and then simply copy all the files form my HDD back on the micro SD card? I think in theory, this should work, right? Or am I missing something important here? Would I 'miss' some files or hidden partitions?

You'll miss symbolic links, if you have any (unless you're backing up the files using Linux and your destination filesystem supports symbolic links).

You can check which symbolic links you have by running this command on the MiSTer's Linux (other linux systems won't recognize the symbolic links in the MiSTer's exFAT, as that's a hack made for MiSTer's linux only):

Code: Select all

find /media/fat/ -print0 | xargs -0 ls -ld | grep ^l

The shorter find /media/fat/ -type l -ls doesn't work for some reason, probably related to the fact that symbolic links in exFAT are a hack.


Re: How to backup SD card

Posted: Sat Sep 21, 2024 7:05 am
by INT806

And is there a way I can also copy the symlinks? I am using Windows 11 or Apple MacOS. Unfortunately I do not have any Linux PCs.


Re: How to backup SD card

Posted: Sat Sep 21, 2024 10:24 am
by pgimeno

No, you'll have to do it manually. List them with the above, saving the result to a file. You can do that with this:

find /media/fat/ -xdev -print0 | xargs -0 ls -ld | grep ^l > symlinks.txt

(I forgot the -xdev in the previous post, though I don't think it would be an issue to omit it in this case). Copy the symlinks.txt file to your computer. Then after restoring the files, for each file in the list which was a symlink (which will be converted to a regular file containing just the link destination path), do this in the MiSTer's Linux command line:

Code: Select all

ln -sf <link value> <link name>

For example, if you have this:

lrwxr-xr-x 1 root root 39 Apr 18 2022 /media/fat/linux/timezone -> /usr/share/zoneinfo/posix/Europe/Madrid

then do:

Code: Select all

ln -sf /usr/share/zoneinfo/posix/Europe/Madrid /media/fat/linux/timezone

Note the arguments swapped with respect to what ls lists.

It's not likely you will have many of these, or maybe any at all.


Re: How to backup SD card

Posted: Sat Sep 21, 2024 10:47 am
by dickhardpill
INT806 wrote: Sat Sep 21, 2024 7:05 am

And is there a way I can also copy the symlinks? I am using Windows 11 or Apple MacOS. Unfortunately I do not have any Linux PCs.

Windows Subsystem for Linux (WSL) is probably my favorite Windows feature. Highly recommended. Great way for someone to dip their toes if they don’t have experience with or an extra PC to install Linux.


Re: How to backup SD card

Posted: Sat Sep 21, 2024 1:08 pm
by pgimeno
dickhardpill wrote: Sat Sep 21, 2024 10:47 am
INT806 wrote: Sat Sep 21, 2024 7:05 am

And is there a way I can also copy the symlinks? I am using Windows 11 or Apple MacOS. Unfortunately I do not have any Linux PCs.

Windows Subsystem for Linux (WSL) is probably my favorite Windows feature. Highly recommended. Great way for someone to dip their toes if they don’t have experience with or an extra PC to install Linux.

This option is not for the faint of heart, though. The symlinks in the SD card won't be visible in systems other than MiSTer, because it has a custom exFAT driver that adds explicit support for symlinks (added by Sorgelig). So, plugging the SD card into your PC and using Linux is not enough per se to copy the symlinks. The only option I can think of that allows it to work, is to use sshfs to remotely mount MiSTer's filesystem, and do the backup to another Linux system that way, which will include symlinks.

Identifying the symlinks (which there will probably be few) and rebuilding them after the restoring is probably simpler for users that are not Linux regulars.

As for how many there are, YMMV but probably very few if any. My case is this: I have a mix of partitions, with a very short exFAT partition able to hold the bare minimum (linux, the MiSTer main executable, the menu core and little else), and then everything else symlinks to the other partition, which is formatted in ext4. So I have all the main folders (_Arcade, _Computer, games, settings, etc) as symlinks to the ext4 partition. I also have a few soundfonts pointing to their right place in the ext4 partition. Besides that, the only other symlinks I have in the exFAT partition are the timezone (which I used as an example in the previous post) and the menu's background image, and that's all.