How to backup SD card

For topics which do not fit in other specific forums.
Robgus
Posts: 90
Joined: Sun Feb 21, 2021 3:52 pm
Has thanked: 62 times
Been thanked: 6 times

How to backup SD card

Unread post 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!
cursedverses
Posts: 180
Joined: Sun May 24, 2020 9:13 pm
Has thanked: 186 times
Been thanked: 34 times

Re: How to backup SD card

Unread post 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)
Robgus
Posts: 90
Joined: Sun Feb 21, 2021 3:52 pm
Has thanked: 62 times
Been thanked: 6 times

Re: How to backup SD card

Unread post 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
Blitzwing
Posts: 103
Joined: Sat Sep 05, 2020 9:52 pm
Has thanked: 11 times
Been thanked: 24 times

Re: How to backup SD card

Unread post 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.
zorrobandito
Posts: 79
Joined: Thu Feb 25, 2021 10:19 pm
Has thanked: 65 times
Been thanked: 19 times

Re: How to backup SD card

Unread post 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)?
User avatar
darksakul
Posts: 353
Joined: Mon May 25, 2020 4:34 pm
Has thanked: 397 times
Been thanked: 73 times

Re: How to backup SD card

Unread post 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.
It is my great regret that we live in an age that is proud of machines that think and suspicious of people who try to.
Blitzwing
Posts: 103
Joined: Sat Sep 05, 2020 9:52 pm
Has thanked: 11 times
Been thanked: 24 times

Re: How to backup SD card

Unread post 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.
Pepeart
Posts: 74
Joined: Thu Sep 17, 2020 3:21 am
Has thanked: 59 times
Been thanked: 5 times

Re: How to backup SD card

Unread post by Pepeart »

I have a backup image that I created using win32 diskimager.
User avatar
INT806
Posts: 9
Joined: Sat Oct 29, 2022 4:46 pm
Location: Munich, Germany
Has thanked: 7 times
Been thanked: 12 times

Re: How to backup SD card

Unread post 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?

User avatar
Waifu4Life
Posts: 271
Joined: Fri Jun 19, 2020 5:30 am
Has thanked: 21 times
Been thanked: 47 times

Re: How to backup SD card

Unread post by Waifu4Life »

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

User avatar
pgimeno
Top Contributor
Posts: 709
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 277 times
Been thanked: 226 times

Re: How to backup SD card

Unread post 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.

User avatar
INT806
Posts: 9
Joined: Sat Oct 29, 2022 4:46 pm
Location: Munich, Germany
Has thanked: 7 times
Been thanked: 12 times

Re: How to backup SD card

Unread post 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.

User avatar
pgimeno
Top Contributor
Posts: 709
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 277 times
Been thanked: 226 times

Re: How to backup SD card

Unread post 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.

User avatar
dickhardpill
Posts: 285
Joined: Tue Apr 09, 2024 9:28 pm
Location: Not Portland, OR
Has thanked: 73 times
Been thanked: 59 times
Contact:

Re: How to backup SD card

Unread post 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.

I has a you tube
Analog IO
USB board
VGA > Component
HDMI > FPM

User avatar
pgimeno
Top Contributor
Posts: 709
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 277 times
Been thanked: 226 times

Re: How to backup SD card

Unread post 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.

Post Reply