]>
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 | ||
36 | Backup Storage | |
37 | -------------- | |
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 | ||
44 | Scheduled Backup | |
45 | ---------------- | |
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 | ||
51 | There are several ways to provide consistency (option `mode`), | |
52 | depending on the guest type. | |
82b4917a | 53 | |
01d37422 DM |
54 | .Backup `mode` for VMs: |
55 | ||
56 | `stop` mode:: | |
57 | ||
58 | This first performns a clean shutdown of the VM to make sure it is | |
59 | stopped. It then starts the VM in suspended mode and uses the qemu | |
60 | backup feature to dump all data. If the VM was running, we start | |
61 | (resume) it immediately after starting the qemu backup task. This | |
62 | keeps the downtime as low as possible. | |
63 | ||
64 | `suspend` mode:: | |
65 | ||
66 | This mode does not really make sense for qemu. Please use snapshot | |
67 | mode instead. | |
68 | ||
69 | `snapshot` mode:: | |
70 | ||
71 | This mode simply starts a qemu live backup task. If the guest agent | |
72 | is enabled (`agent: 1`) and running, it calls 'guest-fsfreeze-freeze' | |
73 | and 'guest-fsfreeze-thaw' to improve consistency. | |
74 | ||
75 | A technical overview of the Proxmox VE live backup for QemuServer can | |
76 | be found online | |
fccf8df6 | 77 | https://git.proxmox.com/?p=pve-qemu-kvm.git;a=blob;f=backup.txt[here]. |
01d37422 | 78 | |
d083d3d3 DM |
79 | NOTE: Qemu backup provides snapshots on any storage type. It does |
80 | not require that the underlying storage supports snapshots. | |
81 | ||
01d37422 DM |
82 | |
83 | .Backup `mode` for Containers: | |
82b4917a DM |
84 | |
85 | `stop` mode:: | |
86 | ||
8e4bb261 FG |
87 | Stop the container for the duration of the backup. This potentially results in |
88 | a very long downtime. | |
82b4917a DM |
89 | |
90 | `suspend` mode:: | |
91 | ||
01d37422 | 92 | This mode uses rsync to copy the container data to a temporary |
6c60aebf EK |
93 | location (see option `--tmpdir`). Then the container is suspended and a second |
94 | rsync copies changed files. After that, the container is started (resumed) | |
871e1fd6 | 95 | again. This results in minimal downtime, but needs additional space |
6c60aebf | 96 | to hold the container copy. |
0006064d | 97 | + |
6c60aebf EK |
98 | When the container is on a local filesystem and the target storage of the backup |
99 | is an NFS server, you should set `--tmpdir` to reside on a local filesystem too, | |
100 | as this will result in a many fold performance improvement. | |
8e4bb261 FG |
101 | Use of a local `tmpdir` is also required if you want to backup a local container |
102 | using ACLs in suspend mode if the backup storage is an NFS server. | |
82b4917a DM |
103 | |
104 | `snapshot` mode:: | |
105 | ||
01d37422 | 106 | This mode uses the snapshotting facilities of the underlying |
b74af7b6 FG |
107 | storage. First, the container will be suspended to ensure data consistency. |
108 | A temporary snapshot of the container's volumes will be made and the | |
109 | snapshot content will be archived in a tar file. Finally, the temporary | |
110 | snapshot is deleted again. | |
111 | ||
112 | NOTE: `snapshot` mode requires that all backed up volumes are on a storage that | |
113 | supports snapshots. Using the `backup=no` mountpoint option individual volumes | |
114 | can be excluded from the backup (and thus this requirement). | |
82b4917a | 115 | |
21c12755 FG |
116 | NOTE: bind and device mountpoints are skipped during backup operations, like |
117 | volume mountpoints with the backup option disabled. | |
118 | ||
82b4917a DM |
119 | |
120 | Backup File Names | |
121 | ----------------- | |
122 | ||
8e4bb261 | 123 | Newer versions of vzdump encode the guest type and the |
82b4917a DM |
124 | backup time into the filename, for example |
125 | ||
126 | vzdump-lxc-105-2009_10_09-11_04_43.tar | |
127 | ||
871e1fd6 | 128 | That way it is possible to store several backup in the same |
82b4917a | 129 | directory. The parameter `maxfiles` can be used to specify the |
871e1fd6 | 130 | maximum number of backups to keep. |
82b4917a DM |
131 | |
132 | Restore | |
133 | ------- | |
134 | ||
135 | The resulting archive files can be restored with the following programs. | |
136 | ||
137 | ||
871e1fd6 | 138 | `pct restore`:: Container restore utility |
82b4917a DM |
139 | |
140 | `qmrestore`:: QemuServer restore utility | |
141 | ||
142 | For details see the corresponding manual pages. | |
143 | ||
144 | Configuration | |
145 | ------------- | |
146 | ||
d083d3d3 DM |
147 | Global configuration is stored in '/etc/vzdump.conf'. The file uses a |
148 | simple colon separated key/value format. Each line has the following | |
149 | format: | |
150 | ||
151 | OPTION: value | |
152 | ||
153 | Blank lines in the file are ignored, and lines starting with a '#' | |
956afd0a DM |
154 | character are treated as comments and are also ignored. Values from |
155 | this file are used as default, and can be overwritten on the command | |
156 | line. | |
d083d3d3 DM |
157 | |
158 | We currently support the following options: | |
159 | ||
160 | include::vzdump.conf.5-opts.adoc[] | |
161 | ||
162 | ||
163 | .Example 'vzdump.conf' Configuration | |
164 | ---- | |
165 | tmpdir: /mnt/fast_local_disk | |
166 | storage: my_backup_storage | |
167 | mode: snapshot | |
168 | bwlimit: 10000 | |
169 | ---- | |
82b4917a DM |
170 | |
171 | Hook Scripts | |
172 | ------------ | |
173 | ||
174 | You can specify a hook script with option `--script`. This script is | |
175 | called at various phases of the backup process, with parameters | |
176 | accordingly set. You can find an example in the documentation | |
177 | directory ('vzdump-hook-script.pl'). | |
178 | ||
179 | File Exclusions | |
180 | --------------- | |
181 | ||
8e4bb261 FG |
182 | NOTE: this option is only available for container backups. |
183 | ||
184 | 'vzdump' skips the following files by default (disable with the option | |
185 | `--stdexcludes 0`) | |
82b4917a | 186 | |
bf01f882 WB |
187 | /tmp/?* |
188 | /var/tmp/?* | |
189 | /var/run/?*pid | |
82b4917a | 190 | |
8e4bb261 | 191 | You can also manually specify (additional) exclude paths, for example: |
82b4917a | 192 | |
bf01f882 | 193 | # vzdump 777 --exclude-path /tmp/ --exclude-path '/var/foo*' |
82b4917a DM |
194 | |
195 | (only excludes tmp directories) | |
196 | ||
197 | Configuration files are also stored inside the backup archive | |
65647b07 | 198 | (in `./etc/vzdump/`) and will be correctly restored. |
82b4917a DM |
199 | |
200 | Examples | |
201 | -------- | |
202 | ||
c31f32a9 | 203 | Simply dump guest 777 - no snapshot, just archive the guest private area and |
82b4917a | 204 | configuration files to the default dump directory (usually |
65647b07 | 205 | '/var/lib/vz/dump/'). |
82b4917a DM |
206 | |
207 | # vzdump 777 | |
208 | ||
871e1fd6 | 209 | Use rsync and suspend/resume to create a snapshot (minimal downtime). |
82b4917a DM |
210 | |
211 | # vzdump 777 --mode suspend | |
212 | ||
c31f32a9 | 213 | Backup all guest systems and send notification mails to root and admin. |
82b4917a DM |
214 | |
215 | # vzdump --all --mode suspend --mailto root --mailto admin | |
216 | ||
b74af7b6 | 217 | Use snapshot mode (no downtime) and non-default dump directory. |
82b4917a DM |
218 | |
219 | # vzdump 777 --dumpdir /mnt/backup --mode snapshot | |
220 | ||
c31f32a9 | 221 | Backup more than one guest (selectively) |
82b4917a DM |
222 | |
223 | # vzdump 101 102 103 --mailto root | |
224 | ||
c31f32a9 | 225 | Backup all guests excluding 101 and 102 |
82b4917a DM |
226 | |
227 | # vzdump --mode suspend --exclude 101,102 | |
228 | ||
c31f32a9 | 229 | Restore a container to a new CT 600 |
82b4917a DM |
230 | |
231 | # pct restore 600 /mnt/backup/vzdump-lxc-777.tar | |
232 | ||
c31f32a9 | 233 | Restore a QemuServer VM to VM 601 |
82b4917a DM |
234 | |
235 | # qmrestore /mnt/backup/vzdump-qemu-888.vma 601 | |
236 | ||
237 | Clone an existing container 101 to a new container 300 with a 4GB root | |
238 | file system, using pipes | |
239 | ||
240 | # vzdump 101 --stdout | pct restore --rootfs 4 300 - | |
241 | ||
242 | ||
243 | ifdef::manvolnum[] | |
244 | include::pve-copyright.adoc[] | |
245 | endif::manvolnum[] | |
246 |