Skip to content

Commit b1ee173

Browse files
tmpfs volume. all compress/encrypt/tar combos functional
1 parent dcc9171 commit b1ee173

7 files changed

Lines changed: 84 additions & 49 deletions

File tree

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ file be damaged.
88
Other similar solutions using encryption result in total data
99
loss past failed incremental archive file.
1010

11+
## Help
12+
13+
Access program command line options with
14+
15+
bacchus --help
16+
1117
## Building
1218

1319
argbash located outside of repo dir was used for building the command line argument parsing
1420

1521
script built with
1622

17-
../argbash/bin/argbash source/bacchus.m4 -o bacchus.sh
23+
../argbash/bin/argbash source/bacchus.m4 -o bacchus.sh
1824

1925
then parser script built with
2026

21-
../argbash/bin/argbash --strip user-content "source/bacchus-parsing.m4" -o "scripts/bacchus-parsing.sh"
22-
23-
## Notes
24-
25-
1) If password was special characters, like symbols, it
26-
might be necessary to wrap password in 'apostrophes'
27+
../argbash/bin/argbash --strip user-content "source/bacchus-parsing.m4" -o "scripts/bacchus-parsing.sh"

bacchus.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Restore()
7171
printf '|| Running Bacchus restore operation ||\n'
7272
printf ' =====================================\n'
7373
PrintOptions
74-
if [ "$_arg_decryptdir" != "." ]; then
74+
if [ "$_arg_decryptdir" != "." ] && [ -n "$password" ]; then
7575
printf 'Intermediate decryption directory: %s\n' "$_arg_decryptdir"
7676
fi
7777
printf '\n'
@@ -106,9 +106,11 @@ fi
106106

107107
BCS_PASSWORD="$password"
108108
BCS_VERBOSETAR="$_arg_verbosetar"
109+
BCS_DISABLECOMPRESS="$_arg_disablecompress"
109110

110111
export BCS_PASSWORD
111112
export BCS_VERBOSETAR
113+
export BCS_DISABLECOMPRESS
112114

113115
case ${_arg_subcommand} in
114116
backup)

scripts/bacchus-backup-new-volume.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
destdir="$1"
1212
compressdir="$2"
1313

14-
tardir=$(dirname "$TAR_ARCHIVE")
14+
tararchivedir=$(dirname "$TAR_ARCHIVE")
1515
TAR_ARCHIVE=$(basename "$TAR_ARCHIVE")
1616
name=$(expr "$TAR_ARCHIVE" : '\(.*\)-.*')
1717
vol=${name:-"$TAR_ARCHIVE"}-"$TAR_VOLUME"
@@ -25,21 +25,26 @@ case "$TAR_SUBCOMMAND" in
2525
*) exit 1
2626
esac
2727

28-
if [ -n "$BCS_PASSWORD" ]; then
29-
compressdest="$compressdir"
30-
else
31-
compressdest="$destdir"
28+
source="$tararchivedir"/"$TAR_ARCHIVE"
29+
destination="$destdir"/"$TAR_ARCHIVE"
30+
31+
if [ "$BCS_DISABLECOMPRESS" == "off" ]; then
32+
if [ -n "$BCS_PASSWORD" ]; then
33+
destination="$compressdir"/"$TAR_ARCHIVE"
34+
fi
35+
pigz -9c "$source" > "$destination".gz
36+
#gzip -9c "$source" > "$destination".gz
37+
rm -f "$source"
38+
source="$destination".gz
39+
destination="$destdir"/"$TAR_ARCHIVE".gz
3240
fi
33-
pigz -9c "$tardir"/"$TAR_ARCHIVE" > "$compressdest"/"$TAR_ARCHIVE".gz
34-
#gzip -9c "$tardir"/"$TAR_ARCHIVE" > "$compressdest"/"$TAR_ARCHIVE".gz
35-
rm "$tardir"/"$TAR_ARCHIVE"
3641

3742
if [ -n "$BCS_PASSWORD" ]; then
38-
echo "$BCS_PASSWORD" | gpg -qc --cipher-algo AES256 --compress-algo none --batch --passphrase-fd 0 -o "$destdir"/"$TAR_ARCHIVE".gz.gpg "$compressdest"/"$TAR_ARCHIVE".gz
39-
rm -f "$compressdest"/"$TAR_ARCHIVE".gz
43+
echo "$BCS_PASSWORD" | gpg -qc --cipher-algo AES256 --compress-algo none --batch --passphrase-fd 0 -o "$destination".gpg "$source"
44+
rm -f "$source"
4045
fi
4146

42-
tarnew="$tardir"/"$vol"
47+
tarnew="$tararchivedir"/"$vol"
4348
case "$TAR_FD" in
4449
none) exit 0
4550
;;

scripts/bacchus-backup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Cleanup()
4343
BCS_TMPFILE=$(mktemp -u /tmp/baccus-XXXXXX)
4444
trap Cleanup EXIT
4545

46+
if [ "$BCS_DISABLECOMPRESS" == "on" ] && [ -z "$BCS_PASSWORD" ]; then
47+
tardir="$destdir"
48+
fi
49+
4650
if [ "$BCS_VERBOSETAR" == "on" ]; then
4751
tarargs='-cpMv'
4852
else

scripts/bacchus-restore-new-volume.sh

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,40 @@ oldname="${TAR_ARCHIVE##*/}"
2020

2121
echo "$filename"
2222

23+
source="$sourcedir"/"$filename"
24+
if [ "$BCS_DISABLECOMPRESS" == "off" ]; then
25+
source="$source".gz
26+
rm -f "$compressdir"/"$oldname"
27+
fi
28+
if [ -n "$BCS_PASSWORD" ]; then
29+
source="$source".gpg
30+
rm -f "$decryptdir"/"$oldname"
31+
fi
32+
2333
case "$TAR_SUBCOMMAND" in
24-
-x) if [ -n "$BCS_PASSWORD" ]; then
25-
test -r "$sourcedir"/"$filename".gz.gpg || exit 1
26-
else
27-
test -r "$sourcedir"/"$filename".gz || exit 1
28-
fi
34+
-x) test -r "$source" || exit 1
2935
;;
3036
*) exit 1
3137
esac
3238

33-
rm "$compressdir"/"$oldname"
34-
3539
if [ -n "$BCS_PASSWORD" ]; then
36-
echo "$BCS_PASSWORD" | gpg -qd --batch --cipher-algo AES256 --compress-algo none --passphrase-fd 0 --no-mdc-warning -o "$decryptdir"/"$filename".gz "$sourcedir"/"$filename".gz.gpg
37-
compresssource="$decryptdir"
38-
else
39-
compresssource="$sourcedir"
40+
if [ "$BCS_DISABLECOMPRESS" == "off" ]; then
41+
destination="$decryptdir"/"$filename".gz
42+
else
43+
destination="$decryptdir"/"$filename"
44+
fi
45+
echo "$BCS_PASSWORD" | gpg -qd --batch --cipher-algo AES256 --compress-algo none --passphrase-fd 0 --no-mdc-warning -o "$destination" "$source"
46+
source="$destination"
4047
fi
4148

42-
pigz -9cd "$compresssource"/"$filename".gz > "$compressdir"/"$filename"
43-
#gzip -9cd "$compresssource"/"$filename".gz > "$compressdir"/"$filename"
44-
if [ -n "$BCS_PASSWORD" ]; then
45-
rm -f "$decryptdir"/"$filename".gz
49+
if [ "$BCS_DISABLECOMPRESS" == "off" ]; then
50+
destination="$compressdir"/"$filename"
51+
pigz -9cd "$source" > "$destination"
52+
#gzip -9cd "$source" > "$destination"
53+
if [ -n "$BCS_PASSWORD" ]; then
54+
rm -f "$source"
55+
fi
56+
source="$destination"
4657
fi
4758

4859
case "$TAR_FD" in

scripts/bacchus-restore.sh

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
# Other similar solutions using encryption result in total data
1111
# loss of past failed incremental archive file.
1212
#
13-
# NOTE: Execute this script from within the directory you want to
14-
# put the restored files
15-
#
1613
# usage:
1714
# bacchus-restore.sh sourcedir destdir basename decryptdir compressdir
1815
#
@@ -48,17 +45,30 @@ trap Cleanup EXIT
4845
# process first (possibly only) backup volume
4946
echo "$basename".tar
5047

51-
if [ -n "$BCS_PASSWORD" ]; then
52-
echo "$BCS_PASSWORD" | gpg -qd --batch --cipher-algo AES256 --compress-algo none --passphrase-fd 0 --no-mdc-warning -o "$decryptdir"/"$basename".tar.gz "$sourcedir"/"$basename".tar.gz.gpg
53-
compresssource="$decryptdir"
54-
else
55-
compresssource="$sourcedir"
48+
source="$sourcedir"/"$basename".tar
49+
50+
if [ "$BCS_DISABLECOMPRESS" == "off" ]; then
51+
source="$source".gz
5652
fi
5753

58-
pigz -9cd "$compresssource"/"$basename".tar.gz > "$compressdir"/"$basename".tar
59-
#gzip -9cd "$compresssource"/"$basename".tar.gz > "$compressdir"/"$basename".tar
6054
if [ -n "$BCS_PASSWORD" ]; then
61-
rm -f "$decryptdir"/"$basename".tar.gz
55+
if [ "$BCS_DISABLECOMPRESS" == "off" ]; then
56+
destination="$decryptdir"/"$basename".tar.gz
57+
else
58+
destination="$decryptdir"/"$basename".tar
59+
fi
60+
echo "$BCS_PASSWORD" | gpg -qd --batch --cipher-algo AES256 --compress-algo none --passphrase-fd 0 --no-mdc-warning -o "$destination" "$source".gpg
61+
source="$destination"
62+
fi
63+
64+
if [ "$BCS_DISABLECOMPRESS" == "off" ]; then
65+
destination="$compressdir"/"$basename".tar
66+
pigz -9cd "$source" > "$destination"
67+
#gzip -9cd "$source" > "$destination"
68+
if [ -n "$BCS_PASSWORD" ]; then
69+
rm -f "$source"
70+
fi
71+
source="$destination"
6272
fi
6373

6474
if [ "$BCS_VERBOSETAR" == "on" ]; then
@@ -67,11 +77,11 @@ else
6777
tarargs='-xpM'
6878
fi
6979

70-
tar "$tarargs" --format posix --new-volume-script "$scriptdir/bacchus-restore-new-volume.sh $sourcedir $decryptdir $compressdir" --volno-file "$BCS_TMPFILE" -f "$compressdir"/"$basename".tar --directory "$destdir"
80+
tar "$tarargs" --format posix --new-volume-script "$scriptdir/bacchus-restore-new-volume.sh $sourcedir $decryptdir $compressdir" --volno-file "$BCS_TMPFILE" -f "$source" --directory "$destdir"
7181

7282
vol=$(cat "$BCS_TMPFILE")
7383
case "$vol" in
74-
1) rm "$compressdir"/"$basename".tar
84+
1) rm "$source"
7585
;;
76-
*) rm "$compressdir"/"$basename".tar-"$vol"
86+
*) rm "$source"-"$vol"
7787
esac

source/bacchus.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Restore()
7171
printf '|| Running Bacchus restore operation ||\n'
7272
printf ' =====================================\n'
7373
PrintOptions
74-
if [[ "$_arg_decryptdir" != "." ]]; then
74+
if [[ "$_arg_decryptdir" != "." ]] && [[ -n "$password" ]]; then
7575
printf 'Intermediate decryption directory: %s\n' "$_arg_decryptdir"
7676
fi
7777
printf '\n'
@@ -106,9 +106,11 @@ fi
106106

107107
BCS_PASSWORD="$password"
108108
BCS_VERBOSETAR="$_arg_verbosetar"
109+
BCS_DISABLECOMPRESS="$_arg_disablecompress"
109110

110111
export BCS_PASSWORD
111112
export BCS_VERBOSETAR
113+
export BCS_DISABLECOMPRESS
112114

113115
case ${_arg_subcommand} in
114116
backup)

0 commit comments

Comments
 (0)