You are not logged in.

#1 2009-09-16 14:03:06

A Future Pilot
Member
Registered: 2008-10-17
Posts: 120

Configuration Backup Script

Is there something like this that will backup all the system config files, and any others that you would want? It'd have to be something like reading from a text file, that has a list of files to backup, So that you can add any other files you wanted. Is there already something like that? Or would I have to make it myself, and if I did, what language should I use, and how would I go about it? I don't know much programming, but I can learn. This might be a good project. What do y'all think?

Offline

#2 2009-09-16 14:12:20

sHyLoCk
Member
From: /dev/null
Registered: 2009-06-19
Posts: 1,197

Re: Configuration Backup Script

This is what I do, please modify it according to your needs and I'm sure there are others who are better at scripting than me here who will be able to provide you with better scripts. take this just as an example.

#!/bin/bash
echo "        Backup Process started!"
echo "        Please wait..."
mkdir -v /windows/Linux-Backup
cp -R /home/shy/.config/* /windows/Linux-Backup
cp /home/shy/.info.pl /windows/Linux-Backup
cp /home/shy/.notify.py /windows/Linux-Backup
cp /home/shy/.weather.sh /windows/Linux-Backup
cp /etc/X11/xorg.conf /windows/Linux-Backup
cp /boot/grub/menu.lst /windows/Linux-Backup
cp /etc/pacman.conf /windows/Linux-Backup
cp /etc/pacman.d/mirrorlist /windows/Linux-Backup
cp -R /home/shy/.scripts /windows/Linux-Backup
cp -R /home/shy/Scripts /windows/Linux-Backup
cp -R /home/shy/Backups /windows/Linux-Backup
cp -R /home/shy/.mozilla /windows/Linux-Backup
cp /home/shy/.xinitrc /windows/Linux-Backup
cp /home/shy/.Xdefaults /windows/Linux-Backup
cp /home/shy/.conk* /windows/Linux-Backup
cp /home/shy/.gtkrc* /windows/Linux-Backup
cp  /home/shy/.bashrc /windows/Linux-Backup
echo "        Backup Process Complete!"
sleep 2 && echo "        Shutting Down....."
echo

Save as backup.sh

And then this:

#!/bin/bash
## Script to call backup.sh
echo "        Do you want to BackUp your System now ? (y/n) : "
read now
case "$now" in
    [nN]*) echo "        BackUp Cancelled!" ;;
    [yY]*) backup.sh ;;
            *) echo "        BackUp Terminated by default! Bad option!" 
esac

Save as backupcall.sh

# chmod +x backup.sh
# chmod +x backupcall.sh
# cp backupcall.sh /usr/bin
# cp backup.sh /usr/bin

You may want to put it in /etc/rc.local.shutdown

#!/bin/bash
backupcall.sh

Please note that everytime you shutdown the script will ask your confirmation. This is really not needed, but I like it this way for being safe.:P You can ignore the last step and just type in terminal backupcall and it will run the script. You can also add it in cron as a daily job.

Last edited by sHyLoCk (2009-09-16 15:03:55)


~ Regards,
sHy
ArchBang: Yet another Distro for Allan to break.
Blog | GIT | Forum (。◕‿◕。)

Offline

#3 2009-09-16 14:23:58

A Future Pilot
Member
Registered: 2008-10-17
Posts: 120

Re: Configuration Backup Script

Cool! Thanks!

Is there a list somewhere of all the config files on the system?

Offline

#4 2009-09-16 14:37:12

Andrwe
Member
From: Leipzig/Germany
Registered: 2009-06-17
Posts: 322
Website

Re: Configuration Backup Script

Try these ones:

http://www.seiichiro0185.org/doku.php/l … kupscripts

There are two scripts, one for home directories backup which copy the changed and new files of the given homedir to the backupdir and one which do a full system backup and save it into a tar.gz.
The configuration is done in the script and very easy if you have some questions about it just ask.

Offline

#5 2009-09-16 22:34:28

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: Configuration Backup Script

A Future Pilot wrote:

It'd have to be something like reading from a text file, that has a list of files to backup, So that you can add any other files you wanted. Is there already something like that?

http://aur.archlinux.org/packages.php?ID=26777
Even maintains a rolling daily, weekly, monthly copy of your backups wink

Last edited by fukawi2 (2009-09-16 22:35:02)

Offline

#6 2009-09-17 01:57:28

xduugu
Member
Registered: 2008-10-16
Posts: 292

Re: Configuration Backup Script

You could also give rdiff-backup a try.

My (simple) script:

su -c "rdiff-backup \
            --preserve-numerical-ids \
            --include-globbing-filelist archbackup \
            -v5 \
        / /mnt/backups/$(uname -n)"

archbackup file:

- **/lost+found

+ /boot/grub/grub.cfg
+ /etc
+ /home/xduugu
+ /srv/http
+ /var/lib/pacman/local

- /

Offline

#7 2009-09-17 02:32:19

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Configuration Backup Script

I write a package inventory to a file in /etc, and then save /boot/grub/menu.lst, /etc and my home directory to an encrypted USB disk using rsync:

#!/bin/bash

if [ `id -u` != "0" ] ; then
  echo "You must be root"
  exit 1
fi

logger -t backup "backup started"

cryptsetup luksOpen /dev/rawbackup lb
mount /dev/mapper/lb /backup || exit 3

pacman -Qqe > /etc/pkglist.txt

sync

rsync -aiPRAX --delete \
/boot/grub/menu.lst \
/etc/ \
/home/ataraxia \
/backup/rsync

sync

umount /backup
cryptsetup luksClose lb

logger -t backup "backup finished"

/dev/rawbackup is created by a udev rule based on the serial number of the backup disk.

Last edited by ataraxia (2009-09-17 02:33:01)

Offline

Board footer

Powered by FluxBB