working backup
This commit is contained in:
parent
6d3532bc16
commit
e2e7ffb75e
4 changed files with 176 additions and 118 deletions
|
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
get_key() {
|
||||
hostname=$1
|
||||
ip=$2
|
||||
ssh "admin@$ip" -- 'if [ ! -f /home/admin/.ssh/id_ed25519.pub ]; then ssh-keygen -t ed25519; fi'
|
||||
pubkey=$(ssh "admin@$ip" cat '$HOME/.ssh/id*.pub')
|
||||
echo 'command="mkdir -p /borg/'"$hostname"'; cd /borg/'"$hostname"'; borg serve --restrict-to-path /borg/'"$hostname"'", restrict '"$pubkey"
|
||||
pubkey=$(ssh "admin@$ip" sudo cat '/etc/ssh/ssh_host_ed25519_key.pub')
|
||||
echo 'command="mkdir -p /borg/'"$hostname"'; cd /borg/'"$hostname"'; borg serve --restrict-to-path /borg/'"$hostname"'",restrict '"$pubkey"
|
||||
}
|
||||
|
||||
put_key() {
|
||||
|
|
@ -15,4 +16,16 @@ put_key() {
|
|||
ssh -t robert@xalicas "sudo -u backup mkdir -p ~backup/.ssh; echo '$line' | sudo -u backup tee -a ~backup/.ssh/authorized_keys"
|
||||
}
|
||||
|
||||
manually_debug_borg_command() {
|
||||
jobname="$1"
|
||||
service="/etc/systemd/system/borgbackup-job-$jobname.service"
|
||||
borg_rsh=$(grep BORG_RSH "$service" | cut -d= -f3 | sed 's/"$//')
|
||||
borg_repo=$(grep BORG_REPO "$service" | cut -d= -f3 | sed 's/"$//')
|
||||
script1=$(grep ExecStart "$service" | cut -d= -f2 | sed 's/ $//')
|
||||
script2=$(grep '^exec' "$script1" | cut -d\ -f2)
|
||||
set -x
|
||||
sudo env BORG_RSH="$borg_rsh" BORG_REPO="$borg_repo" "$script2" || true
|
||||
set +x
|
||||
}
|
||||
|
||||
"$@"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue