summaryrefslogtreecommitdiffstats
path: root/rescue/Flash/scripts/backup_systemloop
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-07-05 13:55:45 +0000
committerOlivier Blin <oblin@mandriva.com>2007-07-05 13:55:45 +0000
commit5bf0ea82a312b21ed600c615f75953efcd203363 (patch)
tree1298634443c610b2c101537f6960cac89ebf5bd0 /rescue/Flash/scripts/backup_systemloop
parent3aa29a9d3a01072b942382aff369ee74c3b93a05 (diff)
downloaddrakx-5bf0ea82a312b21ed600c615f75953efcd203363.tar
drakx-5bf0ea82a312b21ed600c615f75953efcd203363.tar.gz
drakx-5bf0ea82a312b21ed600c615f75953efcd203363.tar.bz2
drakx-5bf0ea82a312b21ed600c615f75953efcd203363.tar.xz
drakx-5bf0ea82a312b21ed600c615f75953efcd203363.zip
move rescue-Flash/scripts as rescue/Flash/scripts
Diffstat (limited to 'rescue/Flash/scripts/backup_systemloop')
-rwxr-xr-xrescue/Flash/scripts/backup_systemloop106
1 files changed, 106 insertions, 0 deletions
diff --git a/rescue/Flash/scripts/backup_systemloop b/rescue/Flash/scripts/backup_systemloop
new file mode 100755
index 000000000..65c3185e6
--- /dev/null
+++ b/rescue/Flash/scripts/backup_systemloop
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+# import functions library
+source rescue_common
+
+tmpdir="/tmp/flash-rescue-root"
+rootdir="$tmpdir/pen"
+
+function prepare() {
+
+ mkdir -p $rootdir
+
+ if ! mount_usbroot $rootdir; then
+ return 1
+ fi
+
+ if [ x"$version" = x"1.0" ]; then
+ mkdir -p $tmpdir/shared
+ if ! mount_sharedroot $tmpdir/shared; then
+ return 1
+ fi
+ fi
+
+ if [ ! -d $dir ]; then
+ mkdir $dir
+ fi
+
+ return 0
+}
+
+function doit() {
+
+ clear
+ echo
+ echo -n 'Creating backup file. This can take some time: '
+
+ bzip2 -c $loop > $target 2> /tmp/rescue-backup.err &
+
+ sleep 2
+
+ while ps | grep -q bzip2; do
+ progress
+ done
+
+ sync
+
+ echo
+ echo
+
+ errsize=$(ls -la /tmp/rescue-backup.err | cut -d' ' -f5)
+ if [ $errsize -ne 0 ]; then
+ echo "Error compressing user files into $target"
+ return 1
+ else
+ echo 'Backup file created!'
+ fi
+
+ echo
+
+ return 0
+}
+
+function cleanup() {
+
+ if [ x"$version" = x"1.0" ]; then
+ umount $tmpdir/shared > /dev/null 2>&1
+ rmdir $tmpdir/shared
+ fi
+
+ umount $rootdir > /dev/null 2>&1
+ rmdir $rootdir $tmpdir 2> /dev/null
+
+ return 0
+}
+
+clear
+trap cleanup SIGINT
+
+version=""
+if ! insert_pendrive; then
+ exit 1
+fi
+
+if [ x"$version" = x"1.0" ]; then
+ dir="$tmpdir/shared/backup"
+ loop="$rootdir/loopbacks/system.loop"
+else
+ dir="$rootdir/backup"
+ loop="$rootdir/.loopbacks/system.loop"
+fi
+
+file="backup-$(date +%Y%m%d).bz2"
+target="$dir/$file"
+
+if ! prepare; then
+ cleanup
+ exit 1
+fi
+
+if ! doit; then
+ cleanup
+ exit 1
+fi
+
+cleanup
+exit 0