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