System backup and system live guide
OviOS Linux Live is a method to use OviOS only running from a live CD without having to install.
OviOS Linux boots the live image writable in memory, allowing the system to be configured as if it was installed. The challenge here is to save the configuration in case of an intentional or unintentional reboot.
Saving and restoring the configuration in OviOS Linux live is very simple and straightforward.
1. Define an OS Backup Pool.
This is a storage pool that will contain a small volume called "osbackup". The system will store here system backups.
For example, if the pool is called "OVIOSPOOL"
ovios-shell> options system.backup.pool OVIOSPOOL
Changing option: system.backup.pool ==> OVIOSPOOL
Note: If you want to reset this option, use reset, or like other options type ""
This means a pool named "reset" wouldn't work.
ovios-shell> options system.backup.pool reset
ovios-shell> options system.backup.pool ""
Changing option: system.backup.pool ==>
2. Define files and / or directories to be backed up.
By default, sync-config (the tool used for backups) backs up the following system configuration files and directories:
Usually, when using OviOS Live, at least the network files should be added to this list.
Add files with options files.to.sync:
ovios-shell> options files.to.sync "/etc/sysconfig/ov-net/ /etc/ypserv.conf /etc/yp.conf"
Changing option: files.to.sync ==> /etc/sysconfig/ov-net/ /etc/ypserv.conf /etc/yp.conf
In this example we added the ov-net directory which contains the network configuration files, and the yp.conf and ypserv.conf files.
You must use this format as in the example above, leave spaces to separate different files and folders.
3. Create a backup.
Run the sync-config tool with option bo or backup-only. If it's the first time you run it, the osbackup dataset will be created and the backup will be written there.
ovios-shell> sync-config bo
osbackup dataset doesn't exist on OVIOSPOOL. Creating now..
Created osbackup dataset
Creating /ovios/OVIOSPOOL/osbackup/osbackup-2020-10-19_13-14-31.tar.gz ...
Created backup osbackup-2020-10-19_13-14-31.tar.gz
If the osbackup dataset already exists, the sync-config tool will create a new backup on it.
ovios-shell> sync-config bo
Found backup location to be /ovios/OVIOSPOOL/osbackup
Creating /ovios/OVIOSPOOL/osbackup/osbackup-2020-10-19_13-14-55.tar.gz ...
Created backup osbackup-2020-10-19_13-14-55.tar.gz
4. Restore after a reboot.
After a reboot (or in any situation when the Admin needs to restore the config from a backup), make sure the OS system backup pool is imported.
You need to disable the skip.import option, enable forced import if this is a live system, and run zfs-admin start.
ovios-shell> options skip.import off
Changing option: skip.import ==> off
ovios-shell> options force.import on
Changing option: force.import ==> on
ovios-shell> zfs-admin start
Starting importing pools
SPL Module already loaded
ZFS Module already loaded
* Starting the ZFS Event Daemon... [ OK ]
* Importing OVIOSPOOL... [ OK ]
* Starting mount on all datasets... [ OK ]
* Starting share on all datasets... [ OK ]
Drop to the bash shell, if at this point you are in the ovios-shell, change directory to your root filesystem (/) and extract the latest backup.
Dropping to the Linux bash shell...
ovios-indt:~ # cd /
ovios-indt:/ # tar xvf /ovios/OVIOSPOOL/osbackup/osbackup-2020-10-19_13-14-
ovios-indt:/ # tar xvf /ovios/OVIOSPOOL/osbackup/osbackup-2020-10-19_13-14-55.tar.gz
After this step, you should run:
ovios-indt:/ # exit
To go back to the ovios-shell.
Then, to start up the interfaces and re-assign the IPs:
ovios-shell> services restart network
* Stopping dhcpcd on the eth0 interface... [ OK ]
Bringing up the eth0 interface...
Starting dhcpcd on the eth0 interface...DUID 00:01:00:01:1f:3e:93:d8:10:c3:7b:45:c0:fc
eth0: IAID 29:e4:50:77
eth0: rebinding lease of 192.168.43.139
eth0: leased 192.168.43.139 for 1800 seconds
eth0: changing route to 192.168.43.0/24
eth0: changing default route via 192.168.43.2
forked to background, child pid 6605
* [ OK ]
ovios-shell> services start
To start all services which were previously enabled with the "options" command.