]>
Commit | Line | Data |
---|---|---|
82b4917a DM |
1 | ifdef::manvolnum[] |
2 | PVE({manvolnum}) | |
3 | ================ | |
38fd0958 | 4 | include::attributes.txt[] |
82b4917a DM |
5 | |
6 | NAME | |
7 | ---- | |
8 | ||
9 | vzdump - Backup Utility for VMs and Containers | |
10 | ||
11 | ||
12 | SYNOPSYS | |
13 | -------- | |
14 | ||
15 | include::vzdump.1-synopsis.adoc[] | |
16 | ||
17 | ||
18 | DESCRIPTION | |
19 | ----------- | |
20 | endif::manvolnum[] | |
21 | ||
22 | ifndef::manvolnum[] | |
23 | Backup and Restore | |
24 | ================== | |
38fd0958 | 25 | include::attributes.txt[] |
82b4917a DM |
26 | endif::manvolnum[] |
27 | ||
12b04941 EK |
28 | Backups are a requirements for any sensible IT deployment, and {pve} |
29 | provides a fully integrated solution, using the capabilities of each storage | |
30 | and each guest system type. This allows the system administrator to fine tune via | |
31 | the `mode` option between consistency of the backups and downtime of the guest | |
32 | system. Proxmox VE backups are always full backups - containing the VM/CT | |
33 | configuration and all data. | |
34 | Backups can be started via the GUI or via the `vzdump` command line tool. | |
35 | ||
c7678c11 EK |
36 | .Backup Storage |
37 | ||
12b04941 EK |
38 | Before a backup can run, a backup storage must be defined. |
39 | Refer to the Storage documentation on how to add a storage. A backup storage | |
40 | must be a file level storage, as backups are stored as regular files. | |
41 | In most situations, using a NFS server is a good way to store backups. | |
42 | You can save those backups later to a tape drive, for off-site archive. | |
43 | ||
c7678c11 EK |
44 | .Scheduled Backup |
45 | ||
12b04941 EK |
46 | Backup jobs can be scheduled so that they are executed automatically on |
47 | specific days and times, for selectable nodes and guest systems. | |
48 | Configuration of scheduled backups is done at the Datacenter level in the GUI, | |
49 | which will generate a cron entry in /etc/cron.d/vzdump. | |
50 | ||
c7678c11 EK |
51 | Backup modes |
52 | ------------ | |
12b04941 EK |
53 | There are several ways to provide consistency (option `mode`), |
54 | depending on the guest type. | |
82b4917a | 55 | |
c7678c11 | 56 | .Backup modes for VMs: |
01d37422 DM |
57 | |
58 | `stop` mode:: | |
c7678c11 EK |
59 | This mode provides the highest consistency of the backup, at the |
60 | cost of a downtime in the VM operation. | |
61 | It works by executing an orderly shutdown of the VM, and then runs a background | |
62 | Qemu process to backup the VM data. After the backup is complete, the | |
63 | Qemu process resumes the VM to full operation mode if it was previously running. | |
01d37422 DM |
64 | |
65 | `suspend` mode:: | |
66 | ||
c7678c11 EK |
67 | This mode is provided for compatibility reason, and suspends the VM before |
68 | calling the `snapshot` mode. Since suspending the VM results in a longer | |
69 | downtime and does not necessarily improve the data consistency, | |
70 | the use of the `snapshot` mode is recommended instead. | |
01d37422 DM |
71 | |
72 | `snapshot` mode:: | |
73 | ||
c7678c11 EK |
74 | This mode provides the lowest operation downtime, at the cost of a small |
75 | inconstancy risk. | |
76 | It works by performing a Proxmox VE live backup, in which data blocks are copy | |
77 | while the VM is running. If the guest agent is enabled (`agent: 1`) and running, | |
78 | it calls 'guest-fsfreeze-freeze' and 'guest-fsfreeze-thaw' to improve | |
79 | consistency. | |
01d37422 DM |
80 | |
81 | A technical overview of the Proxmox VE live backup for QemuServer can | |
82 | be found online | |
fccf8df6 | 83 | https://git.proxmox.com/?p=pve-qemu-kvm.git;a=blob;f=backup.txt[here]. |
01d37422 | 84 | |
c7678c11 EK |
85 | NOTE: For VMs, this _snapshot_ mode relates to the fact that the backup is |
86 | performed while the VM is running. This has here nothing to do with file systems | |
87 | snapshots and can be operated on any kind of storage. | |
01d37422 | 88 | |
c7678c11 | 89 | .Backup modes for Containers: |
82b4917a DM |
90 | |
91 | `stop` mode:: | |
92 | ||
8e4bb261 FG |
93 | Stop the container for the duration of the backup. This potentially results in |
94 | a very long downtime. | |
82b4917a DM |
95 | |
96 | `suspend` mode:: | |
97 | ||
01d37422 | 98 | This mode uses rsync to copy the container data to a temporary |
6c60aebf EK |
99 | location (see option `--tmpdir`). Then the container is suspended and a second |
100 | rsync copies changed files. After that, the container is started (resumed) | |
871e1fd6 | 101 | again. This results in minimal downtime, but needs additional space |
6c60aebf | 102 | to hold the container copy. |
0006064d | 103 | + |
6c60aebf EK |
104 | When the container is on a local filesystem and the target storage of the backup |
105 | is an NFS server, you should set `--tmpdir` to reside on a local filesystem too, | |
106 | as this will result in a many fold performance improvement. | |
8e4bb261 FG |
107 | Use of a local `tmpdir` is also required if you want to backup a local container |
108 | using ACLs in suspend mode if the backup storage is an NFS server. | |
82b4917a DM |
109 | |
110 | `snapshot` mode:: | |
111 | ||
01d37422 | 112 | This mode uses the snapshotting facilities of the underlying |
b74af7b6 FG |
113 | storage. First, the container will be suspended to ensure data consistency. |
114 | A temporary snapshot of the container's volumes will be made and the | |
115 | snapshot content will be archived in a tar file. Finally, the temporary | |
116 | snapshot is deleted again. | |
117 | ||
118 | NOTE: `snapshot` mode requires that all backed up volumes are on a storage that | |
119 | supports snapshots. Using the `backup=no` mountpoint option individual volumes | |
120 | can be excluded from the backup (and thus this requirement). | |
82b4917a | 121 | |
21c12755 FG |
122 | NOTE: bind and device mountpoints are skipped during backup operations, like |
123 | volume mountpoints with the backup option disabled. | |
124 | ||
82b4917a DM |
125 | |
126 | Backup File Names | |
127 | ----------------- | |
128 | ||
8e4bb261 | 129 | Newer versions of vzdump encode the guest type and the |
82b4917a DM |
130 | backup time into the filename, for example |
131 | ||
132 | vzdump-lxc-105-2009_10_09-11_04_43.tar | |
133 | ||
871e1fd6 | 134 | That way it is possible to store several backup in the same |
82b4917a | 135 | directory. The parameter `maxfiles` can be used to specify the |
871e1fd6 | 136 | maximum number of backups to keep. |
82b4917a DM |
137 | |
138 | Restore | |
139 | ------- | |
140 | ||
141 | The resulting archive files can be restored with the following programs. | |
142 | ||
143 | ||
871e1fd6 | 144 | `pct restore`:: Container restore utility |
82b4917a DM |
145 | |
146 | `qmrestore`:: QemuServer restore utility | |
147 | ||
148 | For details see the corresponding manual pages. | |
149 | ||
150 | Configuration | |
151 | ------------- | |
152 | ||
d083d3d3 DM |
153 | Global configuration is stored in '/etc/vzdump.conf'. The file uses a |
154 | simple colon separated key/value format. Each line has the following | |
155 | format: | |
156 | ||
157 | OPTION: value | |
158 | ||
159 | Blank lines in the file are ignored, and lines starting with a '#' | |
956afd0a DM |
160 | character are treated as comments and are also ignored. Values from |
161 | this file are used as default, and can be overwritten on the command | |
162 | line. | |
d083d3d3 DM |
163 | |
164 | We currently support the following options: | |
165 | ||
166 | include::vzdump.conf.5-opts.adoc[] | |
167 | ||
168 | ||
169 | .Example 'vzdump.conf' Configuration | |
170 | ---- | |
171 | tmpdir: /mnt/fast_local_disk | |
172 | storage: my_backup_storage | |
173 | mode: snapshot | |
174 | bwlimit: 10000 | |
175 | ---- | |
82b4917a DM |
176 | |
177 | Hook Scripts | |
178 | ------------ | |
179 | ||
180 | You can specify a hook script with option `--script`. This script is | |
181 | called at various phases of the backup process, with parameters | |
182 | accordingly set. You can find an example in the documentation | |
183 | directory ('vzdump-hook-script.pl'). | |
184 | ||
185 | File Exclusions | |
186 | --------------- | |
187 | ||
8e4bb261 FG |
188 | NOTE: this option is only available for container backups. |
189 | ||
190 | 'vzdump' skips the following files by default (disable with the option | |
191 | `--stdexcludes 0`) | |
82b4917a | 192 | |
bf01f882 WB |
193 | /tmp/?* |
194 | /var/tmp/?* | |
195 | /var/run/?*pid | |
82b4917a | 196 | |
8e4bb261 | 197 | You can also manually specify (additional) exclude paths, for example: |
82b4917a | 198 | |
bf01f882 | 199 | # vzdump 777 --exclude-path /tmp/ --exclude-path '/var/foo*' |
82b4917a DM |
200 | |
201 | (only excludes tmp directories) | |
202 | ||
203 | Configuration files are also stored inside the backup archive | |
65647b07 | 204 | (in `./etc/vzdump/`) and will be correctly restored. |
82b4917a DM |
205 | |
206 | Examples | |
207 | -------- | |
208 | ||
c31f32a9 | 209 | Simply dump guest 777 - no snapshot, just archive the guest private area and |
82b4917a | 210 | configuration files to the default dump directory (usually |
65647b07 | 211 | '/var/lib/vz/dump/'). |
82b4917a DM |
212 | |
213 | # vzdump 777 | |
214 | ||
871e1fd6 | 215 | Use rsync and suspend/resume to create a snapshot (minimal downtime). |
82b4917a DM |
216 | |
217 | # vzdump 777 --mode suspend | |
218 | ||
c31f32a9 | 219 | Backup all guest systems and send notification mails to root and admin. |
82b4917a DM |
220 | |
221 | # vzdump --all --mode suspend --mailto root --mailto admin | |
222 | ||
b74af7b6 | 223 | Use snapshot mode (no downtime) and non-default dump directory. |
82b4917a DM |
224 | |
225 | # vzdump 777 --dumpdir /mnt/backup --mode snapshot | |
226 | ||
c31f32a9 | 227 | Backup more than one guest (selectively) |
82b4917a DM |
228 | |
229 | # vzdump 101 102 103 --mailto root | |
230 | ||
c31f32a9 | 231 | Backup all guests excluding 101 and 102 |
82b4917a DM |
232 | |
233 | # vzdump --mode suspend --exclude 101,102 | |
234 | ||
c31f32a9 | 235 | Restore a container to a new CT 600 |
82b4917a DM |
236 | |
237 | # pct restore 600 /mnt/backup/vzdump-lxc-777.tar | |
238 | ||
c31f32a9 | 239 | Restore a QemuServer VM to VM 601 |
82b4917a DM |
240 | |
241 | # qmrestore /mnt/backup/vzdump-qemu-888.vma 601 | |
242 | ||
243 | Clone an existing container 101 to a new container 300 with a 4GB root | |
244 | file system, using pipes | |
245 | ||
246 | # vzdump 101 --stdout | pct restore --rootfs 4 300 - | |
247 | ||
248 | ||
249 | ifdef::manvolnum[] | |
250 | include::pve-copyright.adoc[] | |
251 | endif::manvolnum[] | |
252 |