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' mode '0600'
end 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 code <<-EOF
cat >>/root/.bashrc <<EOL cat >>/root/.bashrc <<EOL
# GENERATED BY CHEF # GENERATED BY CHEF
export BORG_RSH='ssh -i /root/.ssh/borg_rsa' set -o allexport
export BORG_PASSPHRASE=#{borg_credentials["passphrase"]} source ~/.borg_credentials.env
export BORG_REPO='#{borg_credentials["repository"]}' set +o allexport
EOF EOF
not_if "grep -q BORG /root/.bashrc" not_if "grep -q borg_credentials /root/.bashrc"
end end
directory "/root/backups" do directory "/root/backups" do