以下のVagrantfileを使用して、BorgBackupをインストールした仮想マシンを構築する事ができます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.hostname = "ub1804borgbackup"
config.vm.provider :virtualbox do |vbox|
vbox.name = "ub1804borgbackup"
vbox.cpus = 2
vbox.memory = 2048
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
config.vm.network "private_network", ip: "192.168.55.107", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.107", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get -y install language-pack-ja
sed -i.bak -e "s#http://archive.ubuntu.com/ubuntu/#http://ftp.riken.jp/pub/Linux/ubuntu/#g" /etc/apt/sources.list
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
timedatectl set-timezone Asia/Tokyo
# install borgbackup
apt-get update
apt-get -y install borgbackup
mkdir -p /opt/repo
# test execution
mkdir -p sample
cp /vagrant/Vagrantfile sample
# intializa repo
echo 'initialize...'
export BORG_PASSPHRASE=vagrant
borg init -e repokey /opt/repo
# backup
echo 'backup...'
borg create --stats /opt/repo::20190128 /home/vagrant/sample/*
# show
echo 'listing...'
borg list /opt/repo::20190128
# remove original file and restore it.
echo 'restore...'
rm -f /home/vagrant/sample/Vagrantfile
borg extract /opt/repo::20190128
cat ~vagrant/home/vagrant/sample/Vagrantfile
SHELL
end
0 件のコメント:
コメントを投稿