LiveBackup – live linux backup tool

This tiny shell script will allow you to backup the settings and programs from a live linux session to two .tar files. Here’s a list of the tar files and what they do.

  • config/data.tar – Configuration and settings files. (/var and /usr directories) if any of the files in data.tar exists it will be overwritten.
  • config/system.tar – Programs and other settings. Any existing file will not be overwritten. This prevents crashing the system after untaring the archive.

Here’s the source code for the two scripts are listed below. No download needed just use a text editor and save them as a *.sh file.

#!/bin/sh
#load.sh file
echo Heres a list of the operations and error codes, 0 = success>config/load.log
if [ -z $1 ]
then
xterm -e ./load.sh xterm
else
echo ----- data.tar   -----
sudo tar -xvf config/data.tar -C /
echo data.tar $?>>config/load.log
echo ----- system.tar -----
sudo tar -xvf config/system.tar -C / --skip-old-files
echo system.tar $?>>config/load.log
#Add service load commands after this line
#web server
hiawatha
echo hiawatha $?>>config/load.log
jwm -restart
fi
#!/bin/sh
#save.sh file
mkdir config
echo Heres a list of the operations and error codes, 0 = success>config/save.log
if [ -z $1 ]
then
xterm -e ./save.sh xterm
else
echo ---- data.tar     ----
rm config/data.tar
tar -rvf config/data.tar /etc
echo /etc $?>>config/save.log
tar -rvf config/data.tar /var
echo /var $?>>config/save.log
tar -rvf config/data.tar ~
echo home dir $?>>config/save.log
echo ---- system.tar   ----
rm config/system.tar
tar -rvf config/system.tar /usr
echo system.tar $?>>config/save.log
xedit config/save.log
fi

Published by Justin Roeder

I am an electronics engineer and computer programmer that has autism. I learned by myself

Leave a comment

Your email address will not be published. Required fields are marked *