Set up live backups for all VMs #433

Merged
greg merged 21 commits from feature/qemu_snapshots into master 2022-10-22 11:52:27 +00:00
Showing only changes of commit a5b2eb5f97 - Show all commits

View File

@ -12,16 +12,24 @@ file "/root/.ssh/borg_rsa" do
mode '0600'
end
bash "Add borg environment variables for bash" do
file "/root/.borg_credentials.env" do
content <<-EOF
BORG_RSH='ssh -i /root/.ssh/borg_rsa'
BORG_PASSPHRASE=#{borg_credentials["passphrase"]}
BORG_REPO='#{borg_credentials["repository"]}'
EOF
end
bash "Load borg credentials in console sessions" do
code <<-EOF
cat >>/root/.bashrc <<EOL
# GENERATED BY CHEF
export BORG_RSH='ssh -i /root/.ssh/borg_rsa'
export BORG_PASSPHRASE=#{borg_credentials["passphrase"]}
export BORG_REPO='#{borg_credentials["repository"]}'
set -o allexport
source ~/.borg_credentials.env
set +o allexport
EOF
not_if "grep -q BORG /root/.bashrc"
not_if "grep -q borg_credentials /root/.bashrc"
end
directory "/root/backups" do