062013

Linux Config Backup Script Andrew Mallett | Updated June 2013

Data should always be kept separate (slice, partition) from system files and should be backed up regularly. Additionally server configuration files for the operating system and various applications also need to be backed up, in case the server goes belly-up or a new server needs to be built.

Fortunately Unix makes it easy, as everything is just a file and they're all clear text. Using the following script I can back up my entire gateway server config's in 10 seconds, to a remote system and they take up 100Kb of space. Compare that to a Windows Server..

So here's the script. Click inside the iframe and press CTRL A to highlight the code and then copy and paste..

There's a fair bit of fluff there to make it run pretty but basically the script uses Samba to mount a network share, waits for 10 in case the remore file server is busy, creates a new directory based on the current date and time and then copies all the files across to subdirectories. A couple of variables $start and $stop are used to indicate the total backup time.

Note that the cd command is important before the umount at the end, as the script initially changes to the remote directory for the copying. If the script doesn't cd out back to some directory on the local server (in this case root's home), then the script won't be able to unmount the share.

Andy's Configs..

The configs don't change much so I run the whole thing manually from a custom menu, whenever something changes.

And yes, I did write this script after getting caught out. The hard disk died on a Linux Server and although it was quick and easy to reinstall the OS, particularly with the archived configs, I had to rewrite my conky config file, which was extensively customised but not backed up.

100Kb in 10 seconds, f**k I love Unix..

If you're really keen, why not automate the script using cron..

Back

Comments (0)

Name
E-mail (Will not appear online)
Homepage
Title
Comment
;-) :-) :-D :-( :-o :-O B-) :oops: :-[] :-P
To prevent automated Bots form spamming, please enter the text you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
»
This comment form is powered by GentleSource Comment Script. It can be included in PHP or HTML files and allows visitors to leave comments on the website.

Disposable Email   Disposable Email   Temporary Email