Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
backing up your system profile packages as package files
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
corporate_gadfly
n00b
n00b


Joined: 21 Sep 2002
Posts: 29

PostPosted: Wed Dec 04, 2002 8:24 pm    Post subject: backing up your system profile packages as package files Reply with quote

Here's my attempt at creating a script which backs up all the packages in your "system" profile as .tbzs in the /usr/portage/packages/All directory. Note, that stuff that begins with a * in the file /etc/make.profile/packages is part of the system profile. I am sure you can poke holes at this script, but somebody might find it useful. If that's the case then great. Here's a warning, if this script breaks anything on your system, I'm not liable, so use at your own risk.

Code:
#!/bin/bash

LOG=/var/log/system-backup-`date +%Y%m%d%H%M`.log

echo "==============================================================" >> $LOG
date >> $LOG
echo "==============================================================" >> $LOG

echo "Backing up packages." >> $LOG

# grep for everything that begins with a *
# remove * at the beginning (and > or = or <, if present)
# remove everything after a hyphen followed by a digit at the end
# translate new lines to pipe character
# remove the last pipe character
export PKGLIST=`egrep '^\*' /etc/make.profile/packages | sed 's/^\*\(>\|=\|<\)*/
/g; s/-[0-9]\+.*$//g; s/ //g' | tr '\012' '|' | sed 's/|$//g;'`

for PACKAGE in `qpkg -I -v -nc | egrep "$PKGLIST" | sed 's:\(.*\):/var/db/pkg/\1
:'`
do
        echo "Backing up: $PACKAGE"
        echo "Backing up: $PACKAGE" >> $LOG
        if ! /usr/lib/portage/bin/quickpkg $PACKAGE; then
                echo "Backup of $PACKAGE failed! Exiting."
                echo "Backup of $PACKAGE failed! Exiting." >> $LOG
                exit 1
        fi
done
unset PKGLIST


As you can see it is an off-shoot of the update-step1.sh script from the Gentoo upgrade guide.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum