summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2021-01-18 21:13:41 +0100
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2021-01-18 21:13:41 +0100
commit65b28f28ba2ef18a49039eec03bbd19297a5a344 (patch)
tree3ae878f0c2ec810699b5f4683c6e5e1875e1bfd8
parentb22e55da815eac6a8ad4f6846025565f69144cbc (diff)
downloadcrons-65b28f28ba2ef18a49039eec03bbd19297a5a344.tar.gz
crons-65b28f28ba2ef18a49039eec03bbd19297a5a344.tar.bz2
crons-65b28f28ba2ef18a49039eec03bbd19297a5a344.zip
*-backup.sh: use gtar when possible
Normal tar (like on openbsd) does not have all required options Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rwxr-xr-xcustom-backup.sh7
-rwxr-xr-xportage-backup.sh7
-rwxr-xr-xrootfs-backup.sh7
3 files changed, 18 insertions, 3 deletions
diff --git a/custom-backup.sh b/custom-backup.sh
index 64435f4..86fa1f1 100755
--- a/custom-backup.sh
+++ b/custom-backup.sh
@@ -3,6 +3,11 @@
. /etc/crons.conf.d/backup.conf
. /etc/crons.conf.d/custom-backup.conf
+tar=tar
+if type gtar >/dev/null; then
+ tar=gtar
+fi
+
export LANG=en_US
export XZ=${XZ_COMP}
now=`date +%Y-%m-%d`
@@ -22,7 +27,7 @@ for d in $CUSTOM_DIRS; do
chmod u+w,+x $DESTDIR/$d
fi
- tar -cJpf "$DESTDIR/$d/$now.tar.xz" -C / $d
+ $tar -cJpf "$DESTDIR/$d/$now.tar.xz" -C / $d
chown $USER $DESTDIR/$d/$now.tar.xz
chmod $MOD $DESTDIR/$d/$now.tar.xz
done
diff --git a/portage-backup.sh b/portage-backup.sh
index b004666..8fdc5a7 100755
--- a/portage-backup.sh
+++ b/portage-backup.sh
@@ -2,6 +2,11 @@
. /etc/crons.conf.d/backup.conf
+tar=tar
+if type gtar >/dev/null; then
+ tar=gtar
+fi
+
export LANG=en_US
export XZ=${XZ_COMP}
now=`date +%Y-%m-%d`
@@ -22,7 +27,7 @@ if mkdir ${DESTDIR}/{etc,world,sets} 2>/dev/null; then
fi
# create backup
-tar -cJpf "${DESTDIR}/etc/${now}.tar.xz" -C /etc portage
+$tar -cJpf "${DESTDIR}/etc/${now}.tar.xz" -C /etc portage
cat /var/lib/portage/world | gzip > "${DESTDIR}/world/${now}.gz"
cat /var/lib/portage/world_sets | gzip > "${DESTDIR}/sets/${now}.gz"
diff --git a/rootfs-backup.sh b/rootfs-backup.sh
index 1936e04..4b139bb 100755
--- a/rootfs-backup.sh
+++ b/rootfs-backup.sh
@@ -3,6 +3,11 @@
. /etc/crons.conf.d/backup.conf
. /etc/crons.conf.d/rootfs-backup.conf
+tar=tar
+if type gtar >/dev/null; then
+ tar=gtar
+fi
+
export LANG=en_US
export XZ=${XZ_COMP}
umask 077
@@ -26,7 +31,7 @@ if mkdir ${DESTDIR}/rootfs 2>/dev/null; then
fi
# create backup
-tar --exclude-from=${exclude_file} --one-file-system -cJpf \
+$tar --exclude-from=${exclude_file} --one-file-system -cJpf \
"${DESTDIR}/rootfs/${now}.tar.xz" -C / . > "${tmp_file}" 2>&1
# ignore some warnings