blob: 379e449869137a16cbf2d7b19ee19934b5c4f671 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/sh
echo -n "root directory you want backup (/mnt/): "
read ROOT_DIR
echo -n "where you want to save (/home/user): "
read DEST_DIR
bk_coll() {
col=$1
# make copy of packages
mkdir ${BKDIR}/${col}
while read line; do
if [ ! -f /usr/ports/packages/${line} ]; then
echo "Building package: ${line};\n"
name=$(echo ${line} | cut -d "#" -f 1)
sudo prt-get update -fr ${name}
fi
if [ -f /usr/ports/packages/${line} ]; then
echo "Backing up package: ${line}"
echo ${line} >> ${BKDIR}/backup.pkg
cp /usr/ports/packages/${line} ${BKDIR}/${col}/
else
echo "Package not found: ${line}"
echo ${line} >> ${BKDIR}/${col}-notfound.pkg
fi
done < $BKDIR/${col}.pkg
}
# Temporary directory
BKDIR=$(pwd)/bkdir
mkdir -p ${BKDIR}
# must be using gwak instead of sed, xargs and echo
prt-get listinst -v | sed -s s/" "/#/g | xargs -i echo {}.pkg.tar.gz > ${BKDIR}/installed.pkg
# make list and copy installed core packages
prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep "yes /usr/ports/core" | cut -d " " -f 3 > ${BKDIR}/core.pkg
bk_coll "core"
prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep "yes /usr/ports/opt" | cut -d " " -f 3 > $BKDIR/opt.pkg
bk_coll "opt"
prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep "yes /usr/ports/contrib" | cut -d " " -f 3 > $BKDIR/contrib.pkg
bk_coll "contrib"
prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep "yes /usr/ports/xorg" | cut -d " " -f 3 > $BKDIR/xorg.pkg
bk_coll "xorg"
prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep -v "yes /usr/ports/core" | grep -v "yes /usr/ports/opt" | grep -v "yes /usr/ports/contrib" | grep -v "yes /usr/ports/xorg" | grep "yes " | cut -d " " -f 3 > $BKDIR/other.pkg
#echo $DES_DIR
#echo $ROOT_DIR
#
#tar --xattrs -zcpf $DEST_DIR/system-backup-`date '+%Y-%j-%H-%M-%S'`.tar.gz \
# --directory=$ROOT_DIR \
# --exclude=usr/ports \
# --exclude=usr/src \
# --exclude=var/run \
# --exclude=var/lock \
# --exclude=srv \
# --exclude=mnt \
# --exclude=home \
# --exclude=dev \
# --exclude=run \
# --exclude=tmp \
# --exclude=proc \
# --exclude=sys .
|