209
Chapter 15: Advanced Configuration
To check if the backup was saved correctly:
# /etc/scripts/backup-usb list
Ifthiscommanddoesnotdisplay"*config-20May"thentherewasanerrorsavingtheconguration.
Theset-defaultcommandtakesaninputleasanargumentandrenamesitto"default.opg".Thisdefaultconguration
remainsstoredontheUSBdisk.Thenexttimeyouwanttoloadthedefaultcong,itwillbesourcedfromthenewdefault.opg
file. To set a config file as the default:
# /etc/scripts/backup-usb set-default config-20May
To load this default:
# /etc/scripts/backup-usb load-default
To load any other config file:
# /etc/scripts/backup-usb load {filename}
The /etc/scripts/backup-usb script can be executed directly with various COMMANDS or called from other custom scripts you
may create. However it is recommended that you do not customize the /etc/scripts/backup-usb script itself at all.
15.1.9 Backing-up the configuration off-box
IfyoudonothaveaUSBonyourConsoleServeryoucanbackupthecongurationtoanoff-boxle.Beforebackingupyou
needtoarrangeawaytotransferthebackupoff-box.ThiscouldbeviaanNFSshare,aSamba(Windows)sharetoUSB
storageorcopiedoff-boxviathenetwork.Ifbackingupdirectlytooff-boxstorage,makesureitismounted.
/tmp isnotagoodlocationforthebackupexceptasatemporarylocationbeforetransferringitoff-box.The/tmp directory will
not survive a reboot. The /etc/configdirectoryisnotagoodplaceeither,asitwillnotsurvivearestore.
Backup and restore should be done by the root user to ensure correct file permissions are set. The config command is used to
create a backup tarball:
config -e <Output File>
The tarball will be saved to the indicated location. It will contain the contents of the /etc/config/ directory in an uncompressed
and unencrypted form.
Example nfs storage:
# mount -t nfs 192.168.0.2:/backups /mnt # config -e /mnt/b095.config # umount/mnt/
Exampletransferoff-boxviascp:
# config -e /tmp/b095.config
# scp /tmp/b095.config 192.168.0.2:/backups
The config command is also used to restore a backup:
config -i <Input File>
This will extract the contents of the previously created backup to /tmp,andthensynchronizethe /etc/config directory with the
copy in /tmp.
Oneproblemthatcancropuphereisthatthereisnotenoughroomin /tmp to extract files to. The following command will
temporarily increase the size of /tmp:
mount -t tmpfs -o remount,size=2048k tmpfs /var
Ifrestoringtoeitheranewunitoronethathasbeenfactorydefaulted,itisimportanttomakesurethattheprocess
generatingSSHkeysiseitherstoppedorcompletedbeforerestoringconguration.Ifthisisnotdone,thenamixofoldand
new keys may be put in place.
AsSSHusesthesekeystoavoidman-in-the-middleattacks,logginginmaybedisrupted.