about summary refs log tree commit diff stats
path: root/core/scripts/backup-system.sh
diff options
context:
space:
mode:
Diffstat (limited to 'core/scripts/backup-system.sh')
-rw-r--r--core/scripts/backup-system.sh82
1 files changed, 62 insertions, 20 deletions
diff --git a/core/scripts/backup-system.sh b/core/scripts/backup-system.sh
index bc94f7e..379e449 100644
--- a/core/scripts/backup-system.sh
+++ b/core/scripts/backup-system.sh
@@ -6,23 +6,65 @@ read ROOT_DIR
 echo -n "where you want to save (/home/user): "
 read DEST_DIR
 
-echo -n "backup name (system_name): "
-read BCK_NAME
-
-echo $DES_DIR
-echo $ROOT_DIR
-
-tar --xattrs -zcpf $DEST_DIR/$BCK_NAME-`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 .
+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 .