From 3886f96018867badde8b140e29fd7e78b0e3f77f Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Sat, 3 Aug 2024 21:34:46 -0400 Subject: [PATCH] Renamed tools to match gen2-naming --- README.md | 77 ++++++++++++++++++++++++-------------- exstage4.sh => gen2extract | 0 mkstage4.sh => gen2stage4 | 2 +- cpstage4.sh => gen2sync | 0 tests/0001.bats | 2 +- tests/0002.bats | 2 +- tests/0003.bats | 2 +- tests/0004.bats | 2 +- tests/0005.bats | 2 +- tests/0006.bats | 2 +- tests/0007.bats | 4 +- tests/0008.bats | 2 +- tests/test_helper.bash | 4 +- 13 files changed, 60 insertions(+), 41 deletions(-) rename exstage4.sh => gen2extract (100%) rename mkstage4.sh => gen2stage4 (98%) rename cpstage4.sh => gen2sync (100%) diff --git a/README.md b/README.md index 54b44a0..3df21f3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The script can be run directly from its containing folder (and thus, is installe ```bash git clone https://github.com/erenfro/gen2backup.git /your/gen2backup/directory cd /your/mkstagen2backupge4/directory -chmod +x cpstage4.sh exstage4.sh mkstage4.sh +chmod +x gen2sync gen2extract gen2stage4 ``` For [Gentoo Linux](http://en.wikipedia.org/wiki/Gentoo_linux) and [Derivatives](http://en.wikipedia.org/wiki/Category:Gentoo_Linux_derivatives), gen2backup is also available in [Portage](http://en.wikipedia.org/wiki/Portage_(software)) via the base Gentoo overlay. @@ -27,9 +27,9 @@ emerge app-backup/gen2backup ## Usage -*If you are running the script from the containing folder (first install method) please make sure you use the e.g. `./mkstage4.sh` command instead of just `mkstage4`!* +*If you are running the script from the containing folder (first install method) please make sure you use the e.g. `./gen2stage4` command instead of just `gen2stage4`!* -Note that the extension (e.g. `.tar.xz`) will be automatically appended to the `archive_name` string which you specify in calling the `mkstage4` command. +Note that the extension (e.g. `.tar.xz`) will be automatically appended to the `archive_name` string which you specify in calling the `gen2stage4` command. This is done based on the compression type, which can be specifiled via the `-C` parameter, if another compression than the default (`bz2`, creating files ending in `.tar.bz2`) is desired. ### Examples @@ -37,67 +37,87 @@ This is done based on the compression type, which can be specifiled via the `-C` Archive your current system (mounted at /): ```bash -mkstage4 -s archive_name +gen2stage4 -s archive_name ``` -Archive a system located at a custom mount point: +Archive a system located at a custom path: ```bash -mkstage4 -t /custom/mount/point archive_name +gen2stage4 -t /custom/path archive_name ``` Copy a system to a separate drive, e.g. for quick backup. ```bash -cpstage4 / /run/media/myuser/mybackupdrive +gen2sync -s /run/media/myuser/mybackupdrive +``` + +Copy a system located at a custom path: + +```bash +gen2sync -t /custom/path /run/media/myuser/mybackupdrive ``` ### Command line arguments ```console Usage: - mkstage4.sh [-b -c -k -l -q] [-C ] [-s || -t ] [-e ] [-i ] [custom-tar-options] - -b: excludes boot directory. - -c: excludes some confidential files (currently only .bash_history and connman network lists). - -k: separately save current kernel modules and src (creates smaller archives and saves decompression time). - -l: excludes lost+found directory. - -q: activates quiet mode (no confirmation). - -C: specify tar compression (default: bz2, available: lz4 xz bz2 zst gz). - -s: makes tarball of current system. - -t: makes tarball of system located at the . - -e: an additional excludes directory (one dir one -e, donot use it with *). - -i: an additional target to include. This has higher precedence than -e, -t, and -s. - -h: displays help message. +gen2stage4 [-b -c -k -l -q] [-C ] [-s || -t ] [-e ...] [-i ...] [-- [tar-opts]] +Position Arguments: + archive name to create with optional path + [tar-opts] additional options to pass to tar command + +Options: + -b excludes boot directory + -c excludes some confidential files (currently only .bash_history and connman network lists) + -k separately save current kernel modules and src (creates smaller targetArchives and saves decompression time) + -l includes lost+found directory + -q activates quiet mode (no confirmation) + -C specify tar compression (default: ${optCompressType}, available: ${!compressAvail[*]}) + -s makes archive of current system + -t makes archive of system located at the + -e an additional exclude directory (one dir one -e, do not use it with *) + -i an additional include. This has higher precedence than -e, -t, and -s + -h display this help message. ``` ## System Tarball Extraction ### Automatic (Multi-threaded) -We provide a script for convenient extraction, `exstage4`, which is shipped with this package. -Currently it simply automates the Multi-threaded extraction selection listed below and otherwise has no functionality except checking that the file name looks sane. -If in doubt, use one of the explicit extraction methods described below. -Otherwise, you can extract an archive inplace with: +Provides is a script for convenient extraction, `gen2extract`, which is shipped with this package. Currently it simply automates the Multi-threaded extraction selection listed below and otherwise has no functionality except checking that the file name looks sane. +If in doubt, use one of the explicit extraction methods described below. Otherwise, you can extract an archive inplace with: ```bash -exstage4 archive_name.tar.bz2 +gen2extract -s archive_name.tar.bz2 ``` +To extract in the current directory, or: + +```bash +gen2extract -t /target/path archive_name.tar.bz2 +``` +To extract to the target path. ### Explicit Single-threaded -Tarballs created with mkstage4 can be extracted with: +Archives created with gen2stage4 can also be extracted with tar as well. To preserve binary attributes and use numeric owner identifiers, you can simply append the relevant flags to the respective `tar` commands, e.g.: ```bash -tar xvjpf archive_name.tar.bz2 --xattrs-include='*.*' --numeric-owner +tar xvpf archive_name.tar.bz2 --xattrs-include='*.*' --numeric-owner ``` +To extract in the current directory, or: +```bash +tar xvpf archive_name.tar.bz2 --xattrs-include='*.*' --numeric-owner -C /target/path +``` +To extract to the target path. If you use the `-k` option, extract the `src` and modules archives separately: ```bash -tar xvjpf archive_name.tar.bz2.kmod -tar xvjpf archive_name.tar.bz2.ksrc +tar xvpf archive_name.kmod.tar.bz2 +tar xvpf archive_name.ksrc.tar.bz2 ``` ### Explicit Multi-threaded @@ -163,4 +183,3 @@ tar -I unpigz -xvf archive_name.tar.gz --xattrs-include='*.*' --numeric-owner * `-C zstd`: * **[zstd](https://facebook.github.io/zstd/)** - in Portage as **[app-arch/zstd](https://packages.gentoo.org/packages/app-arch/zstd)**, (parallel) - diff --git a/exstage4.sh b/gen2extract similarity index 100% rename from exstage4.sh rename to gen2extract diff --git a/mkstage4.sh b/gen2stage4 similarity index 98% rename from mkstage4.sh rename to gen2stage4 index 44a473e..a3d0f98 100755 --- a/mkstage4.sh +++ b/gen2stage4 @@ -265,7 +265,7 @@ if ! $optQuiet; then echo echo "WARNING: since all data is saved by default the user should exclude all" echo "security- or privacy-related files and directories, which are not" - echo "already excluded by mkstage4 options (such as -c), manually per cmdline." + echo "already excluded by gen2stage4 options (such as -c), manually per cmdline." echo "example: \$ $(basename "$0") -s /my-backup --exclude=/etc/ssh/ssh_host*" echo echo "COMMAND LINE PREVIEW:" diff --git a/cpstage4.sh b/gen2sync similarity index 100% rename from cpstage4.sh rename to gen2sync diff --git a/tests/0001.bats b/tests/0001.bats index 45c5ddd..d64cc51 100644 --- a/tests/0001.bats +++ b/tests/0001.bats @@ -29,7 +29,7 @@ setup() { f test/var/lib/docker/image f test/var/log/messages f test/var/log/portage/elog/.keep_sys-apps_portage-0 - mkstage4.sh -q -t test test + gen2stage4 -q -t test test } teardown() { diff --git a/tests/0002.bats b/tests/0002.bats index ffa6230..5953ea3 100644 --- a/tests/0002.bats +++ b/tests/0002.bats @@ -6,7 +6,7 @@ setup() { f test/usr/bin/ping f test/usr/bin/lost+found f test/lost+found - mkstage4.sh -q -l -t test test + gen2stage4 -q -l -t test test } teardown() { diff --git a/tests/0003.bats b/tests/0003.bats index 3e73f5f..bcc44dd 100644 --- a/tests/0003.bats +++ b/tests/0003.bats @@ -12,7 +12,7 @@ setup() { f test/lib64/modules/"$TEST_UNAME"/mod.ko f test/lib/modules/different-uname/mod.ko f test/lib64/modules/different-uname/mod.ko - mkstage4.sh -k -q -t test test + gen2stage4 -k -q -t test test } teardown() { diff --git a/tests/0004.bats b/tests/0004.bats index cdd1ecf..c396520 100644 --- a/tests/0004.bats +++ b/tests/0004.bats @@ -5,7 +5,7 @@ load test_helper setup() { f test/boot/kernel d test/boot/boot - mkstage4.sh -b -q -t test test + gen2stage4 -b -q -t test test } teardown() { diff --git a/tests/0005.bats b/tests/0005.bats index c198fe2..3b19640 100644 --- a/tests/0005.bats +++ b/tests/0005.bats @@ -6,7 +6,7 @@ setup() { f test/var/lib/connman/file f test/root/.bash_history f test/home/user/.bash_history - mkstage4.sh -c -q -t test test + gen2stage4 -c -q -t test test } teardown() { diff --git a/tests/0006.bats b/tests/0006.bats index 3c3d169..1c91e20 100644 --- a/tests/0006.bats +++ b/tests/0006.bats @@ -7,7 +7,7 @@ setup() { f test/var/db/repos/science/sci-biology/fsl/ebuild f test/var/cache/distfiles/mkstage4.tar.gz f test/usr/portage/Manifest - mkstage4.sh -q -t test test + gen2stage4 -q -t test test } teardown() { diff --git a/tests/0007.bats b/tests/0007.bats index 087391f..ceb984b 100644 --- a/tests/0007.bats +++ b/tests/0007.bats @@ -10,8 +10,8 @@ setup() { f test/home/user/ccache/file f test/root/ccache/file f test/etc/secrets/key - mkstage4.sh -q -t test test0 - mkstage4.sh \ + gen2stage4 -q -t test test0 + gen2stage4 \ -e 'test/lost+found' \ -e 'user/.*' \ -e 'test/home/user/chroot/var/tmp/file' \ diff --git a/tests/0008.bats b/tests/0008.bats index 3908310..c2c037c 100644 --- a/tests/0008.bats +++ b/tests/0008.bats @@ -10,7 +10,7 @@ setup() { f test/boot/boot f test/boot/kernel f test/mnt/5/media - mkstage4.sh \ + gen2stage4 \ -i 'test/home/user/.keep' \ -e 'user/.*' \ -i 'test/etc/ssh/config' \ diff --git a/tests/test_helper.bash b/tests/test_helper.bash index 6385ec4..a753706 100644 --- a/tests/test_helper.bash +++ b/tests/test_helper.bash @@ -3,12 +3,12 @@ test_directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export PATH="$test_directory/..:$PATH" -# export so that uname hook in mkstage4.sh has access to var +# export so that uname hook in gen2stage4 has access to var export TEST_UNAME="test-uname" uname() { echo "$TEST_UNAME"; } export -f uname -# bypasses mkstage4.sh root check +# bypasses gen2stage4 root check whoami() { echo "root"; } export -f whoami