OPNsense Forum

English Forums => General Discussion => Topic started by: crissi on November 24, 2021, 12:46:21 pm

Title: Full Backup / Clone SSD possible, how?
Post by: crissi on November 24, 2021, 12:46:21 pm
Hello,
as i have do add a lot of customization like for Unbound, NTOpng / GeoMaps and DNSCrypt
Proxy, i was wondering if i can clone the whole SSD to another SSD (Cold Standby)
in case if a Power Outage happens, or the System complete crash, etc..

Thx!
Title: Re: Full Backup / Clone SSD possible, how?
Post by: cookiemonster on November 24, 2021, 05:33:29 pm
I have thought about this a little.
The problem with cloning is that if you want to do it when the system is running and the system is not virtualised, then options are fewer. Nothing is already builtin that I am aware of. The main issue is that an OS can't clone itself. It needs something outside of it to clone it.
But then if we're using zfs then there are zfs clone, send > receive, and boot environments to come to some help but is is not cloning.
Title: Re: Full Backup / Clone SSD possible, how?
Post by: crissi on November 25, 2021, 12:43:34 pm
Thx, yes, system is not virtualized. and possible offline option? install freebsd in virtual box and connect both drives via USB, and use dd?
Title: Re: Full Backup / Clone SSD possible, how?
Post by: tiermutter on November 25, 2021, 12:50:19 pm
I used cloned SSD as backup a few years ago, worked fine so far.
Now Im cloning my SSD to images which are saved directy via LAN on my NAS. This works also fine, did a restore on another machine (same hardware) a few months ago, worked perfectly.
For sure this backup is done offline, but it just takes me about 10 minutes.
Title: Re: Full Backup / Clone SSD possible, how?
Post by: fabian on November 25, 2021, 12:51:17 pm
Cold standby is likely not working but hot stand by should work.

Either by using RAID 1 or HAST

https://docs.freebsd.org/en/books/handbook/disks/#disks-hast
Title: Re: Full Backup / Clone SSD possible, how?
Post by: Patrick M. Hausen on November 25, 2021, 01:19:01 pm
The main issue is that an OS can't clone itself. It needs something outside of it to clone it.
Why should an OS not be able to clone itself? Let's assume our single OPNsense disk device is ada0

You now have a complete copy of your OPNsense installation in a single compressed image file on that thumbdrive.

HTH,
Patrick
Title: Re: Full Backup / Clone SSD possible, how?
Post by: cookiemonster on November 25, 2021, 02:40:27 pm
Right but that is not done itself. In your example it was presumably a human connecting the console, booting to single user mode, etc. Unless you tell me how to put that in cron, it is still not itself.
Title: Re: Full Backup / Clone SSD possible, how?
Post by: Patrick M. Hausen on November 25, 2021, 03:56:59 pm
Right but that is not done itself. In your example it was presumably a human connecting the console, booting to single user mode, etc. Unless you tell me how to put that in cron, it is still not itself.
Right. I interpreted your remark as "definitely needs external tooling" - which it doesn't. But you cannot get a consistent clone from the live running system in regular intervals, correct.

OTOH the OP did ask for a single image copy at some single point in time and not for anything automated. So with my command summary it is perfectly possible to generate an image that can be put back on e.g. a new SSD in a very similar fashion.

@crissi - if that is indeed what you need, you can try the procedure I outlined and if it works for you I will of course also tell you how to write that image back onto an SSD.
Title: Re: Full Backup / Clone SSD possible, how?
Post by: cookiemonster on November 25, 2021, 04:17:50 pm
OTOH the IP did ask for a single image copy at some single point in time and not for anything automated. So with my command summary it is perfectly possible to generate an image that can be put back on e.g. a new SSD in a very similar fashion.
That is very true too.
I keep wishing freebsd's ufs or zfs had inexpensive tooling available to do what other OSs can. Have a client on the running OS that can take the backups (full, incremental, etc.) and ship it out to network/other storage. But having the option of block level as well as file level.
Veem springs to mind that I use to backup win clients to a ZFS-based storage appliance. I just have scheduled a regular full baremetal image as the belt and braces element of the backups strategy. I can't use if for OPN though :(
Title: Re: Full Backup / Clone SSD possible, how?
Post by: Patrick M. Hausen on November 25, 2021, 04:34:54 pm
For UFS dump and restore are included, off-system can easily achieved via SSH. Same for ZFS with ZFS snapshots and zfs send|zfs receive. All the tooling is there.
Title: Re: Full Backup / Clone SSD possible, how?
Post by: crissi on November 25, 2021, 06:39:33 pm
@pmhausen

Thx, image is created , how exactly write back?
Title: Re: Full Backup / Clone SSD possible, how?
Post by: Patrick M. Hausen on November 26, 2021, 12:24:21 am
Boot with console connected from OPNsense install USB drive. Don't log in as "installer" but as "root". You now have a live system. If the commands I suggested worked exactly as I wrote, then:
Title: Re: Full Backup / Clone SSD possible, how?
Post by: crissi on November 26, 2021, 09:01:44 am
thanks a lot, the restore of the image worked, fw is up and running again :)

it would be really great, if there would be the possibility in future to implement this in a script / or plugin, and also have the option to send the image to a shared network folder.

Thank you All for your Help!
Title: Re: Full Backup / Clone SSD possible, how?
Post by: lfirewall1243 on November 26, 2021, 10:37:34 am
Isnt it faster to reinstall OPNsense completly (done in 5 Minutes) and import the config Backup?
Title: Re: Full Backup / Clone SSD possible, how?
Post by: cookiemonster on November 26, 2021, 10:48:39 am
Isnt it faster to reinstall OPNsense completly (done in 5 Minutes) and import the config Backup?
I guess not really if there are any custom-changes in the filesystem, see for instance https://forum.opnsense.org/index.php?topic=25736.0 (https://forum.opnsense.org/index.php?topic=25736.0)
Title: Re: Full Backup / Clone SSD possible, how?
Post by: chemlud on November 26, 2021, 11:16:31 am
...or custom cron jobs of custom unbound configs. That's why I don't understand why some things are (made) so difficult in OPNsense. The config.xml should include ANYTHING needed to configure the firewall. Nothing else...
Title: Re: Full Backup / Clone SSD possible, how?
Post by: crissi on November 27, 2021, 10:50:04 am
Quote
The config.xml should include ANYTHING needed to configure the firewall

No, unfortunately not. If you have for Example installed DNSCrypt Proxy Version 211 manually, and if you are using NTOpng Geo Maps and copied over the GEO Files manually to use it, this Files are not available in case of XML Restore...
Title: Re: Full Backup / Clone SSD possible, how?
Post by: Patrick M. Hausen on November 27, 2021, 10:54:04 am
That was his point. It should, but it doesn't.  ;)