]>
Commit | Line | Data |
---|---|---|
9a225ed5 DM |
1 | package PVE::CLI::vzdump; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use PVE::CLIHandler; | |
7 | use PVE::API2::VZDump; | |
8 | ||
9 | use base qw(PVE::CLIHandler); | |
10 | ||
144a2199 DM |
11 | # Note: use string 'vmid' as $arg_param option, to allow vmid lists |
12 | our $cmddef = [ 'PVE::API2::VZDump', 'vzdump', 'vmid', undef, | |
9a225ed5 DM |
13 | sub { |
14 | my $upid = shift; | |
15 | exit(0) if $upid eq 'OK'; | |
16 | my $status = PVE::Tools::upid_read_status($upid); | |
17 | exit($status eq 'OK' ? 0 : -1); | |
18 | }]; | |
19 | ||
20 | 1; | |
21 | ||
22 | __END__ | |
23 | ||
24 | =head1 NAME | |
25 | ||
26 | vzdump - backup utility for virtual machine | |
27 | ||
28 | =head1 SYNOPSIS | |
29 | ||
30 | =include synopsis | |
31 | ||
32 | =head1 DESCRIPTION | |
33 | ||
34 | vzdump is an utility to make consistent snapshots of running virtual | |
35 | machines (VMs). It basically creates an archive of the VM private area, | |
36 | which also includes the VM configuration files. vzdump currently | |
2b290f89 | 37 | supports LXC containers and QemuServer VMs. |
9a225ed5 DM |
38 | |
39 | There are several ways to provide consistency (option C<mode>): | |
40 | ||
41 | =over 2 | |
42 | ||
43 | =item C<stop> mode | |
44 | ||
45 | Stop the VM during backup. This results in a very long downtime. | |
46 | ||
47 | =item C<suspend> mode | |
48 | ||
2b290f89 | 49 | For containers, this mode uses rsync to copy the VM to a temporary |
9a225ed5 DM |
50 | location (see option --tmpdir). Then the VM is suspended and a second |
51 | rsync copies changed files. After that, the VM is started (resume) | |
52 | again. This results in a minimal downtime, but needs additional space | |
53 | to hold the VM copy. | |
54 | ||
0125d38c EK |
55 | For QemuServer, this mode will suspend the VM, start |
56 | a live backup, and resume the VM. | |
9a225ed5 DM |
57 | |
58 | =item C<snapshot> mode | |
59 | ||
0125d38c EK |
60 | For containers, this mode uses the snapshotting facilities of the underlying |
61 | storage. A snapshot will be made of the container volume, and the snapshot content | |
62 | will be archived in a tar file. | |
63 | ||
64 | For QemuServer, this mode will do a live backup similar to the C<snaphost> mode, but without | |
65 | suspending/resuming the VM. | |
9a225ed5 DM |
66 | |
67 | =back | |
68 | ||
0125d38c EK |
69 | A technical overview of the Proxmox VE live backup for QemuServer can be found online at: |
70 | https://git.proxmox.com/?p=pve-qemu-kvm.git;a=blob;f=backup.txt | |
71 | ||
9a225ed5 DM |
72 | =head1 BACKUP FILE NAMES |
73 | ||
74 | Newer version of vzdump encodes the virtual machine type and the | |
75 | backup time into the filename, for example | |
76 | ||
2b290f89 | 77 | vzdump-lxc-105-2009_10_09-11_04_43.tar |
9a225ed5 DM |
78 | |
79 | That way it is possible to store several backup into the same | |
80 | directory. The parameter C<maxfiles> can be used to specify the maximal | |
81 | number of backups to keep. | |
82 | ||
83 | =head1 RESTORE | |
84 | ||
85 | The resulting archive files can be restored with the following programs. | |
86 | ||
87 | =over 1 | |
88 | ||
2b290f89 | 89 | =item pct restore: Containers restore utility |
9a225ed5 DM |
90 | |
91 | =item qmrestore: QemuServer restore utility | |
92 | ||
93 | =back | |
94 | ||
95 | For details see the corresponding manual pages. | |
96 | ||
97 | =head1 CONFIGURATION | |
98 | ||
99 | Global configuration is stored in /etc/vzdump.conf. | |
100 | ||
101 | tmpdir: DIR | |
102 | dumpdir: DIR | |
103 | storage: STORAGE_ID | |
104 | mode: snapshot|suspend|stop | |
105 | bwlimit: KBPS | |
106 | ionize: PRI | |
107 | lockwait: MINUTES | |
108 | stopwait: MINUTES | |
109 | size: MB | |
110 | maxfiles: N | |
111 | script: FILENAME | |
112 | exclude-path: PATHLIST | |
113 | ||
114 | =head1 HOOK SCRIPT | |
115 | ||
116 | You can specify a hook script with option C<--script>. This script is called at various phases of the backup process, with parameters accordingly set. You can find an example in the documentation directory (C<vzdump-hook-script.pl>). | |
117 | ||
2b290f89 | 118 | =head1 EXCLUSIONS (Containers only) |
9a225ed5 DM |
119 | |
120 | vzdump skips the following files wit option --stdexcludes | |
121 | ||
122 | /var/log/.+ | |
123 | /tmp/.+ | |
124 | /var/tmp/.+ | |
125 | /var/run/.+pid | |
126 | ||
127 | You can manually specify exclude paths, for example: | |
128 | ||
d38e9382 | 129 | # vzdump 777 --exclude-path /tmp/ --exclude-path /var/foo* |
9a225ed5 DM |
130 | |
131 | (only excludes tmp directories) | |
132 | ||
133 | Configuration files are also stored inside the backup archive (/etc/vzdump), and will be correctly restored. | |
134 | ||
135 | =head1 LIMITATIONS | |
136 | ||
137 | VZDump does not save ACLs. | |
138 | ||
139 | =head1 EXAMPLES | |
140 | ||
141 | Simply dump VM 777 - no snapshot, just archive the VM private area and configuration files to the default dump directory (usually /vz/dump/). | |
142 | ||
143 | # vzdump 777 | |
144 | ||
145 | Use rsync and suspend/resume to create an snapshot (minimal downtime). | |
146 | ||
147 | # vzdump 777 --mode suspend | |
148 | ||
149 | Backup all VMs and send notification mails to root and admin. | |
150 | ||
151 | # vzdump --all --mode suspend --mailto root --mailto admin | |
152 | ||
153 | Use LVM2 to create snapshots (no downtime). | |
154 | ||
155 | # vzdump 777 --dumpdir /mnt/backup --mode snapshot | |
156 | ||
157 | Backup more than one VM (selectively) | |
158 | ||
159 | # vzdump 101 102 103 --mailto root | |
160 | ||
161 | Backup all VMs excluding VM 101 and 102 | |
162 | ||
163 | # vzdump --mode suspend --exclude 101,102 | |
164 | ||
2b290f89 | 165 | Restore a container to a new VM 600 |
9a225ed5 | 166 | |
2b290f89 | 167 | # pct restore 600 /mnt/backup/vzdump-lxc-777.tar |
9a225ed5 | 168 | |
2b290f89 | 169 | Restore a Qemu/KVM machine to VM 601 |
9a225ed5 DM |
170 | |
171 | # qmrestore /mnt/backup/vzdump-qemu-888.vma 601 | |
172 | ||
2b290f89 | 173 | Clone an existing container 101 to a new container 300 with a 4GB root file system, using pipes |
9a225ed5 | 174 | |
2b290f89 | 175 | # vzdump 101 --stdout | pct restore --rootfs 4 300 - |
9a225ed5 DM |
176 | |
177 | =head1 SEE ALSO | |
178 | ||
2b290f89 | 179 | pct(1), qmrestore(1) |
9a225ed5 DM |
180 | |
181 | =include pve_copyright |