Last active
October 20, 2019 15:59
-
-
Save u1735067/819e9c58c32d902a13d197067c1de21a to your computer and use it in GitHub Desktop.
Workaround to convert simple tar backup to borg backup, without leading path, using ratarmount (should works with archivemount too) and mergerfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p /chroot_tmp/{logs,mnt,archive_mnt,bins_mnt/dev,bins_mnt/lib,bins_mnt/lib64,bins_mnt/tmp/repo} | |
cd /chroot_tmp | |
wget https://github.com/borgbackup/borg/releases/download/1.1.10/borg-linux64 -O /bins_mnt/tmp/borg | |
chmod +x /chroot_tmp/bins_mnt/tmp/borg | |
wget https://www.busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-x86_64 -O /bins_mnt/tmp/busybox | |
chmod +x /chroot_tmp/bins_mnt/tmp/busybox | |
wget https://github.com/mxmlnkn/ratarmount/raw/master/ratarmount.py -O ratarmount.py | |
wget https://github.com/fusepy/fusepy/raw/master/fuse.py -o fuse.py | |
bins_mnt/tmp/borg init --verbose --progress --encryption=repokey-blake2 /chroot_tmp/bins_mnt/tmp/repo | |
# Copy host libs to chroot, required | |
cp -r /lib/x86_64-linux-gnu/ bins_mnt/lib/ | |
cp -r /lib64/ bins_mnt/ | |
cat <<EOF > bins_mnt/tmp/exclude | |
R / | |
- /dev | |
- /lib | |
- /lib64 | |
- /lost+found | |
- /root/.ash_history | |
- /root/.cache | |
- /root/.config/borg | |
- /tmp | |
EOF | |
#epoch=$(date +@%s -d "$(basename "$i" | sed -re "s/.* ([0-9-]+)_([0-9]+)'([0-9]+)'([0-9]+)\..*/\1 \2:\3:\4/")") | |
#utcdate=$(date -u +%Y-%m-%dT%H:%M:%S -d @$(stat -c %Y "$i")) | |
#date=$(date +"%Y-%m-%d_%H:%M:%S" -d $epoch) | |
#gunzip -k my_tar.tgz | |
python3 ratarmount.py -c my_tar.tar archive_mnt/ | |
mount.mergerfs archive_mnt/:bins_mnt/ mnt | |
mount --bind /dev mnt/dev | |
echo "backup" | |
chroot mnt/ /tmp/borg create --show-version --show-rc --verbose --list --stats --one-file-system --exclude-nodump --exclude-caches --keep-exclude-tags --patterns-from /tmp/exclude "/tmp/repo/::archive_name" 2>&1 | tee "logs/archive_name.log" | |
echo "backup dump" | |
zcat archive_mnt/dump.gz | bins_mnt/tmp/borg create --show-version --show-rc --verbose --list --stats --stdin-name dump "bins_mnt/tmp/repo/::archive_name_dump" - 2>&1 | tee "logs/archive_name_dump.log" | |
echo "unmount" | |
umount mnt/dev | |
umount mnt | |
umount archive_mnt/ | |
#rm -f my_tar.tar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://borgbackup.readthedocs.io/en/stable/usage/create.html | |
https://borgbackup.readthedocs.io/en/stable/usage/help.html | |
https://superuser.com/questions/265772/is-it-possible-to-mount-a-tar-file | |
https://github.com/mxmlnkn/ratarmount | |
https://github.com/cybernoid/archivemount/ | |
https://sebsauvage.net/wiki/doku.php?id=borgbackup | |
unix fake chroot | |
https://unix.stackexchange.com/questions/125680/different-fakechroot-behavior-on-fedora-and-ubuntu | |
https://unix.stackexchange.com/questions/66084/simulate-chroot-with-unshare | |
https://unix.stackexchange.com/questions/321361/how-do-i-when-running-an-executable-script-fake-the-root-directory | |
https://manpages.debian.org/wheezy/fakechroot/fakechroot.1 | |
https://manpages.debian.org/testing/fakechroot/fakechroot.1.en.html | |
https://www.busybox.net/downloads/binaries/1.30.0-i686/ | |
https://unix.stackexchange.com/questions/120015/how-to-find-out-the-dynamic-libraries-executables-loads-when-run | |
static libc | |
http://stevehanov.ca/blog/?id=97 | |
static executable "not found" | |
https://amir.rachum.com/blog/2016/09/17/shared-libraries/ | |
https://github.com/gflags/gflags/issues/283 | |
https://unix.stackexchange.com/questions/476971/ldd-shows-no-location-after-arrow-library-does-not-exist-on-system | |
"_rmtree_safe_fd" FileNotFoundError: [Errno 2] No such file or directory: 'config' | |
-> syscall not implemented in fuse | |
ls: Value too large for defined data type | |
https://github.com/GoogleContainerTools/distroless/issues/225 | |
https://unix.stackexchange.com/questions/227312/how-can-i-convert-a-local-date-time-into-utc-date-time | |
https://intoli.com/blog/exit-on-errors-in-bash-scripts/ | |
archivemount : peut modifier les fichiers, gz, lent | |
ratarmount: rapide, bug si pas -c, pas gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment