Compare commits
1 Commits
aa9a72d884
...
9b38c248d8
Author | SHA1 | Date | |
---|---|---|---|
9b38c248d8 |
2
Makefile
2
Makefile
|
@ -38,7 +38,7 @@ rebase:
|
|||
git pull
|
||||
git checkout -
|
||||
git rebase master
|
||||
./initial-setup.sh --update-paths
|
||||
./initial-setup.sh --update
|
||||
systemctl daemon-reload
|
||||
git status
|
||||
|
||||
|
|
16
README.md
16
README.md
|
@ -77,7 +77,7 @@ This doesn't require the repo key. It shouldn't be entered on the untrusted
|
|||
backup host, so for operations that need it, use a trusted host and run borg
|
||||
remotely instead, e.g.:
|
||||
|
||||
${BORG_DIR}/Borg.bin --remote-path borg/borg info ${BACKUP_USER}@${BACKUP_HOST}:borg/${HOSTNAME}
|
||||
${BORG_DIR}/bin/borg --remote-path borg/borg info ${BACKUP_USER}@${BACKUP_HOST}:borg/${HOSTNAME}
|
||||
|
||||
The repo passphrase is in bitwarden `borg ${HOSTNAME} / repo key`.
|
||||
|
||||
|
@ -115,11 +115,12 @@ Design
|
|||
Notes
|
||||
=====
|
||||
|
||||
# Building Borg.bin binary from git
|
||||
# Building Borg binary from git
|
||||
|
||||
sudo apt install python3.9 scons libacl1-dev libfuse-dev libpython3.9-dev patchelf
|
||||
git clone https://github.com/borgbackup/borg.git
|
||||
cd borg
|
||||
virtualenv --python=python3 borg-env
|
||||
virtualenv --python=python3.9 borg-env
|
||||
source borg-env/bin/activate
|
||||
pip install -r requirements.d/development.txt
|
||||
pip install pyinstaller
|
||||
|
@ -127,9 +128,14 @@ Notes
|
|||
pip install -e .[llfuse]
|
||||
pyinstaller --clean --noconfirm scripts/borg.exe.spec
|
||||
pip install staticx
|
||||
staticx -l /lib/x86_64-linux-gnu/libm.so.6 dist/borg.exe Borg.bin
|
||||
|
||||
Then see `dist/borg.exe`. Confirm the version with `dist/borg.exe --version`.
|
||||
# for x86
|
||||
staticx -l /lib/x86_64-linux-gnu/libm.so.6 dist/borg.exe borg.x86_64
|
||||
|
||||
# for ARM; see https://github.com/JonathonReinhart/staticx/issues/209
|
||||
staticx -l /lib/arm-linux-gnueabihf/libm.so.6 dist/borg.exe borg.armv7l
|
||||
|
||||
Then run `borg.x86_64`. Confirm the version with `borg.armv7l --version`.
|
||||
|
||||
*Note:* This uses the deprecated `llfuse` instead of the newer `pyfuse3`.
|
||||
`pyfuse3` doesn't work because, at minimum, it pulls in `trio` which
|
||||
|
|
BIN
bin/borg.armv7l
Executable file
BIN
bin/borg.armv7l
Executable file
Binary file not shown.
|
@ -10,9 +10,7 @@ BACKUP_REPO=${BACKUP_REPO:-borg/${HOSTNAME}}
|
|||
BORG_DIR="$(realpath "$(dirname "$0")")"
|
||||
cd "${BORG_DIR}"
|
||||
|
||||
# This is named with uppercase so that it doesn't tab-complete for
|
||||
# "./b<tab>", which should give us "./borg.sh"
|
||||
BORG_BIN="${BORG_DIR}/Borg.bin"
|
||||
BORG_BIN="${BORG_DIR}/bin/borg.$(uname -m)"
|
||||
|
||||
# Use stable host ID in case MAC address changes
|
||||
HOSTID="${HOSTNAME}@$(python -c 'import uuid;print(uuid.getnode())')"
|
||||
|
@ -27,6 +25,46 @@ trap 'error_handler ${BASH_SOURCE} ${LINENO} $?' ERR
|
|||
set -o errexit
|
||||
set -o errtrace
|
||||
|
||||
# Create pip environment
|
||||
setup_venv()
|
||||
{
|
||||
if ! which pipenv >/dev/null 2>&1 ; then
|
||||
echo "pipenv not found, try: sudo apt install pipenv"
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p .venv
|
||||
pipenv install
|
||||
}
|
||||
|
||||
# Create shell script with environment variables
|
||||
create_borg_vars()
|
||||
{
|
||||
VARS=${BORG_DIR}/vars.sh
|
||||
|
||||
# These variables are used elsewhere in this script
|
||||
BORG_REPO="ssh://${BACKUP_USER}@${BACKUP_HOST}/./${BACKUP_REPO}"
|
||||
BORG=${BORG_DIR}/borg.sh
|
||||
SSH=$BORG_DIR/ssh
|
||||
|
||||
cat >"$VARS" <<EOF
|
||||
export BACKUP_USER=${BACKUP_USER}
|
||||
export BACKUP_HOST=${BACKUP_HOST}
|
||||
export BACKUP_REPO=${BACKUP_REPO}
|
||||
export HOSTNAME=${HOSTNAME}
|
||||
export BORG_REPO=${BORG_REPO}
|
||||
export BORG_HOST_ID=${HOSTID}
|
||||
export BORG_PASSCOMMAND="cat ${BORG_DIR}/passphrase"
|
||||
export BORG_DIR=${BORG_DIR}
|
||||
export SSH=${SSH}
|
||||
export BORG=${BORG}
|
||||
export BORG_BIN=${BORG_BIN}
|
||||
EOF
|
||||
if ! "$BORG" -h >/dev/null ; then
|
||||
error "Can't run the borg wrapper; does borg work?"
|
||||
fi
|
||||
}
|
||||
|
||||
# Update paths in README and backup.py
|
||||
update_paths()
|
||||
{
|
||||
sed -i \
|
||||
|
@ -42,13 +80,16 @@ update_paths()
|
|||
backup.py
|
||||
}
|
||||
|
||||
if [ "$1" == "--update-paths" ] ; then
|
||||
# See if we're just supposed to update an existing install
|
||||
if [ "$1" == "--update-paths" ] || [ "$1" == "--update" ] ; then
|
||||
if [ -e "vars.sh" ]; then
|
||||
echo "Updating paths"
|
||||
echo "Updating paths and variables"
|
||||
update_paths
|
||||
setup_venv
|
||||
update_vars
|
||||
exit 0
|
||||
else
|
||||
echo "Can't update paths, not set up yet"
|
||||
echo "Can't update, not set up yet"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -92,46 +133,6 @@ notice() { msg 32 "$@" ; }
|
|||
warn() { msg 31 "$@" ; }
|
||||
error() { msg 31 "Error:" "$@" ; exit 1 ; }
|
||||
|
||||
# Create pip environment
|
||||
setup_venv()
|
||||
{
|
||||
if ! which pipenv >/dev/null 2>&1 ; then
|
||||
echo "pipenv not found, try: sudo apt install pipenv"
|
||||
exit 1
|
||||
fi
|
||||
mkdir .venv
|
||||
pipenv install
|
||||
}
|
||||
|
||||
# Create shell script with environment variables
|
||||
create_borg_vars()
|
||||
{
|
||||
VARS=${BORG_DIR}/vars.sh
|
||||
|
||||
# These variables are used elsewhere in this script
|
||||
BORG_REPO="ssh://${BACKUP_USER}@${BACKUP_HOST}/./${BACKUP_REPO}"
|
||||
BORG=${BORG_DIR}/borg.sh
|
||||
SSH=$BORG_DIR/ssh
|
||||
|
||||
cat >"$VARS" <<EOF
|
||||
export BACKUP_USER=${BACKUP_USER}
|
||||
export BACKUP_HOST=${BACKUP_HOST}
|
||||
export BACKUP_REPO=${BACKUP_REPO}
|
||||
export HOSTNAME=${HOSTNAME}
|
||||
export BORG_REPO=${BORG_REPO}
|
||||
export BORG_HOST_ID=${HOSTID}
|
||||
export BORG_PASSCOMMAND="cat ${BORG_DIR}/passphrase"
|
||||
export BORG_DIR=${BORG_DIR}
|
||||
export SSH=${SSH}
|
||||
export BORG=${BORG}
|
||||
export BORG_BIN=${BORG_BIN}
|
||||
EOF
|
||||
if ! "$BORG" -h >/dev/null ; then
|
||||
error "Can't run the borg wrapper; does borg work?"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
print_random_key()
|
||||
{
|
||||
dd if=/dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 16
|
||||
|
|
Loading…
Reference in New Issue
Block a user