linux:gentoo-backup
                This is an old revision of the document!
Gentoo System Backup
Refer to
http://forums.gentoo.org/viewtopic-t-65669.html
#!/bin/sh 
# for FULL backups 
# this backs up the important stuffs listed in ${lists} to ${BKPDIR} 
# the lists *should* be in ${BKPDIR} and named <whatever>.lst 
# the resulting backups will be <whatever>.<timestamp>.tgz 
# 
# notes: 
# variables in CAPS are ok for you to set 
# change the other variables if you know what you're doing 
# you can get fancy in the lists... (think xargs *wink*) 
# assumes /boot is usually unmounted, and has an /etc/fstab entry 
# follow your security policy when setting perms on ${BKPDIR} 
# 
# written by razamatan 
# 
# DISCLAIMER: razamatan didn't write this if something goes wrong 
 
BKPDIR=/home/pjq/backup            # where the backups go 
BOOT=boot #sys                        # list that has /boot 
NUMBKPS=3                       # how many backups to keep 
 
if [ ! -d ${BKPDIR} ] ; then 
        echo ${BKPDIR} is not a valid directory or is non-existant 
        exit -1
fi 
 
lists=${BKPDIR}/*.lst 
ext=tgz 
 
for list in `ls ${lists}`; do 
        type=`basename ${list} .lst` 
 
        if [ ${type} = ${BOOT} ] ; then mount /boot ; fi 
        echo cat ${list} | xargs tar zlcvf  ${BKPDIR}/${type}.`date +%Y-%m-%d-%H%M`.${ext} # > /dev/null 2>&1 
        cat ${list} | xargs tar zlcvf  ${BKPDIR}/${type}.`date +%Y-%m-%d-%H%M`.${ext} # > /dev/null 2>&1 
        if [ ${type} = ${BOOT} ] ; then umount /boot ; fi 
 
        num=${NUMBKPS} 
        for evict in `ls -t ${BKPDIR}/${type}.*.${ext}`; do 
                if [ ${num} -le 0 ] ; then rm -f ${evict} 
                else num=$((${num}-1)) ; fi 
        done 
done
/bin /boot /root --exclude=/dev /etc /sbin /lib --exclude=/sys /lib32 /lib64 /usr --exclude=/usr/portage/distfiles --exclude=/usr/src/linux --exclude=/usr/portage /usr/src/linux/.config /var
/var/www/dokuwiki/wiki/data/attic/linux/gentoo-backup.1407599050.txt.gz · Last modified: 2016/05/05 13:06 (external edit)
                
                