Skip to content

Commit

Permalink
Add support backup VM in storage Proxmox VE (pool Ceph)
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Feb 12, 2018
1 parent 3fce35c commit 3624ae2
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.deb
test/
test/
new
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ Commands:
disable Disable backup job from scheduler
status Get list of all backups
clean Clear all backup
reset Remove all snapshots on images specific vm in Ceph
reset Remove all snapshots on images specific VM/CT in Ceph
backup Will backup one time
restore Will restore image one time
assemble Assemble a unique image with diff file. (Require eve4ceph-mdti)
Options:
--vmid The ID of the VM, comma separated (es. 100,101,102),
--vmid The ID of the VM/CT, comma separated (es. 100,101,102),
'all-???' for all known guest systems in specific host (es. all-pve1, all-$(hostname)),
'all' for all known guest systems in cluster
'storage-???' storage Proxmox VE (pool Ceph)
--label Is usually 'hourly', 'daily', 'weekly', or 'monthly'
--path Path destination backup
--keep Specify the number of backup which should will keep, Default 1
Expand Down Expand Up @@ -91,12 +92,13 @@ For _continuous data protection_ see
* For KVM and LXC
* Can keep multiple backup
* Syslog integration
* Multiple schedule VM using --label (es. daily,monthly)
* Multiple schedule VM/CT using --label (es. daily,monthly)
* Hook script
* Multiple VM single execution
* Multiple VM/CT single execution
* Copy config and firewall files
* Export any vm in cluster 'all'
* Export any vm in specific host 'all-hostname'
* Export any VM/CT in cluster 'all'
* Export any VM/CT in specific host 'all-hostname'
* Export any VM/CT in specific pool
* Show size of backup and incremental
* Check 'No backup' flag in disk configuration
* Protected/unprotected snap mode
Expand All @@ -115,7 +117,7 @@ Whit parameter **--unprotect-snap** is possible to disable protection snap.

## Configuration and use

Download package eve4pve-barc_?.?.?-?_all.deb, on your Proxmox VE host and
Download package eve4pve-barc\_?.?.?-?\_all.deb, on your Proxmox VE host and
install:

```sh
Expand All @@ -125,13 +127,13 @@ dpkg -i eve4pve-barc_?.?.?-?_all.deb

This tool need basically no configuration.

## Backup a VM one time
## Backup a VM/CT one time

```sh
root@pve1:~# eve4pve-barc backup --vmid=111 --label='daily' --path=/mnt/bckceph --keep=2
```

This command backup VM 111. The --keep tells that it should be kept 2 backup, if
This command backup VM/CT 111. The --keep tells that it should be kept 2 backup, if
there are more than 2 backup, the 3 one will be erased (sorted by creation
time).

Expand Down Expand Up @@ -184,7 +186,7 @@ VM TYPE SIZE BACKUP IMAGE
112 diff 1.9M 17-02-08 17:27:33 pool-rbd.vm-112-disk-1
```

## Restore a VM one time
## Restore a VM/CT one time

```sh
root@pve1:~# eve4pve-barc restore --vmid=111 --label='daily' --path=/mnt/bckceph
Expand Down Expand Up @@ -233,7 +235,7 @@ Backup pool-rbd.vm-111-disk-1 restored in pool-rbd/vm-111-disk-1-restored with s
Consider to manually create VM/CT and change config file from backup adapting restored image.
```

## Assemble make a unique image with diff file.
## Assemble make a unique image with diff file

```sh
root@pve1:~# eve4pve-barc assemble --vmid=111 --label='daily' --path=/mnt/bckceph
Expand Down Expand Up @@ -337,7 +339,7 @@ Writing 29091840 bytes to image
Backup hdd-pool.vm-111-disk-1 assebled in assemble-hdd-pool.vm-111-disk-1 with success!
```

Mount image. For ntfs using offset 1048576
Mount image. For NTFS using offset 1048576

```sh
mount -o loop,offset=1048576 assemble-hdd-pool.vm-11-disk-1.assimg /mnt/imgbck/
Expand Down
8 changes: 8 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
eve4pve-barc (0.1.9)

* Add support backup VM in storage Proxmox VE (pool Ceph)
* Improve log debug
* Improve code

-- EnterpriseVE Support Team <[email protected]> 12 Feb 2018 11:50:01 +0100

eve4pve-barc (0.1.8)

* Initialize arrays to prevent values filled from previous jobs/vm #22
Expand Down
44 changes: 37 additions & 7 deletions eve4pve-barc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# EnterpriseVE Backup And Restore Ceph for Proxmox VE.
# Author: Daniele Corsini <[email protected]>

declare -r VERSION=0.1.8
declare -r VERSION=0.1.9
declare -r NAME=$(basename "$0")
declare -r PROGNAME=${NAME%.*}

Expand Down Expand Up @@ -37,6 +37,7 @@ declare snap_name_prefix=''
declare path_backup=''
declare -i vm_id=0
declare -A vm_ids

function usage(){
shift

Expand Down Expand Up @@ -85,15 +86,16 @@ Commands:
disable Disable backup job from scheduler
status Get list of all backups
clean Clear all backup
reset Remove all snapshots on images specific vm in Ceph
reset Remove all snapshots on images specific VM/CT in Ceph
backup Will backup one time
restore Will restore image one time
assemble Assemble a unique image with diff file. (Require eve4ceph-mdti)
Options:
--vmid The ID of the VM, comma separated (es. 100,101,102),
--vmid The ID of the VM/CT, comma separated (es. 100,101,102),
'all-???' for all known guest systems in specific host (es. all-pve1, all-\$(hostname)),
'all' for all known guest systems in cluster
'all' for all known guest systems in cluster,
'storage-???' storage Proxmox VE (pool Ceph)
--label Is usually 'hourly', 'daily', 'weekly', or 'monthly'
--path Path destination backup
--keep Specify the number of backup which should will keep, Default 1
Expand Down Expand Up @@ -229,15 +231,40 @@ function parse_opts(){

vm_ids=$(echo "$data" | tr ',' '\n')

elif [[ "$opt_vm_ids" == "storage-"* ]]; then
#all in specific storage (pool Ceph)

local storage=${opt_vm_ids#*-}

if ! pvesm list "$storage" > /dev/null 2>&1; then
log info "Pool '$storage' not found in ProxmoxVE storage."
end_process 1
fi

vm_ids=$(pvesm list "$storage" | awk '{print $4}')

else
#comma separated
vm_ids=$(echo "$opt_vm_ids" | tr ',' '\n')

fi

[ -z "$opt_label" ] && { log info "Label is not set correctly"; end_process 1; }
[ "$opt_keep" -le 0 ] && { log info "Keep is not set correctly. Value > 0."; end_process 1; }

snap_name_prefix="barc$opt_label"

if [ $opt_debug -eq 1 ]; then
log info "============================================"
log info "EnterpriseVE BARC Version: $VERSION";
log info "============================================"
log info "Proxmox VE Version:"

#info proxmox
pveversion --verbose

log info "============================================"
fi
}

function get_path(){
Expand Down Expand Up @@ -434,7 +461,7 @@ function backup(){

parse_opts "$@"

log info "EnterpriseVE BARC | Backup"
log info "ACTION: Backup"

local timestamp; timestamp=$(date +%y%m%d%H%M%S)
log info "Start backup $(date "+%F %T")"
Expand Down Expand Up @@ -778,6 +805,8 @@ function reset(){
function restore(){
parse_opts "$@"

log info "ACTION: Restore image"

for vm_id in $vm_ids; do
get_path

Expand Down Expand Up @@ -809,7 +838,7 @@ function restore(){

[ -z "$timestamp" ] && exit 1

#list all ppols
#list all pools
pools=($(rados lspools | awk '{printf "%s %s\n",$1,$1}'))

#select timestamp
Expand Down Expand Up @@ -847,7 +876,7 @@ function restore(){
for backup in $path_backup/*$image*; do
if [[ $backup == *".img" ]]; then
#initial import
log info "Inital import $(basename "$backup")"
log info "Initial import $(basename "$backup")"
do_run "rbd import --image-format 2 '$backup' $pool_name/$name_import"

#create initlal snap name
Expand All @@ -866,6 +895,7 @@ function restore(){
done

#remove all snapshots
log info "Remove all snapshots"
do_run "rbd snap purge $pool_name/$name_import"

log info "Backup $image restored in $pool_name/$name_import with success!"
Expand Down

0 comments on commit 3624ae2

Please sign in to comment.