37 lines
1.1 KiB
Bash
Executable File
37 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Old script to restore a backup to a virtual machine disk (PLAN A)
|
|
#
|
|
# Copyright (C) 2023 Adrien 'neox' Bourmault <neox@a-lec.org>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
vm=$1
|
|
date=$2
|
|
disk=$3
|
|
destpath=$4
|
|
|
|
if [[ $# != 4 ]]
|
|
then
|
|
echo "ERROR: 4 parameters required (vm, date, disk, destination)"
|
|
exit 1
|
|
fi
|
|
|
|
backup_file=$(sudo virt-backup list -D ${vm} | grep ${date} | cut -d " " -f 2 | sed "s/.json/_${disk}.raw/g")
|
|
|
|
echo "Restoring $backup_file"
|
|
sudo cp --sparse=always -v "$backup_file" "$destpath"
|
|
|
|
|
|
|