]>
Commit | Line | Data |
---|---|---|
1 | ifdef::manvolnum[] | |
2 | PVE({manvolnum}) | |
3 | ================ | |
4 | include::attributes.txt[] | |
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 | ================== | |
25 | include::attributes.txt[] | |
26 | endif::manvolnum[] | |
27 | ||
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. | |
53 | ||
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 | |
77 | https://git.proxmox.com/?p=pve-qemu-kvm.git;a=blob;f=backup.txt[here]. | |
78 | ||
79 | NOTE: Qemu backup provides snapshots on any storage type. It does | |
80 | not require that the underlying storage supports snapshots. | |
81 | ||
82 | ||
83 | .Backup `mode` for Containers: | |
84 | ||
85 | `stop` mode:: | |
86 | ||
87 | Stop the container for the duration of the backup. This potentially results in | |
88 | a very long downtime. | |
89 | ||
90 | `suspend` mode:: | |
91 | ||
92 | This mode uses rsync to copy the container data to a temporary | |
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) | |
95 | again. This results in minimal downtime, but needs additional space | |
96 | to hold the container copy. | |
97 | + | |
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. | |
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. | |
103 | ||
104 | `snapshot` mode:: | |
105 | ||
106 | This mode uses the snapshotting facilities of the underlying | |
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). | |
115 | ||
116 | NOTE: bind and device mountpoints are skipped during backup operations, like | |
117 | volume mountpoints with the backup option disabled. | |
118 | ||
119 | ||
120 | Backup File Names | |
121 | ----------------- | |
122 | ||
123 | Newer versions of vzdump encode the guest type and the | |
124 | backup time into the filename, for example | |
125 | ||
126 | vzdump-lxc-105-2009_10_09-11_04_43.tar | |
127 | ||
128 | That way it is possible to store several backup in the same | |
129 | directory. The parameter `maxfiles` can be used to specify the | |
130 | maximum number of backups to keep. | |
131 | ||
132 | Restore | |
133 | ------- | |
134 | ||
135 | The resulting archive files can be restored with the following programs. | |
136 | ||
137 | ||
138 | `pct restore`:: Container restore utility | |
139 | ||
140 | `qmrestore`:: QemuServer restore utility | |
141 | ||
142 | For details see the corresponding manual pages. | |
143 | ||
144 | Configuration | |
145 | ------------- | |
146 | ||
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 '#' | |
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. | |
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 | ---- | |
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 | ||
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`) | |
186 | ||
187 | /tmp/?* | |
188 | /var/tmp/?* | |
189 | /var/run/?*pid | |
190 | ||
191 | You can also manually specify (additional) exclude paths, for example: | |
192 | ||
193 | # vzdump 777 --exclude-path /tmp/ --exclude-path '/var/foo*' | |
194 | ||
195 | (only excludes tmp directories) | |
196 | ||
197 | Configuration files are also stored inside the backup archive | |
198 | (in `./etc/vzdump/`) and will be correctly restored. | |
199 | ||
200 | Examples | |
201 | -------- | |
202 | ||
203 | Simply dump guest 777 - no snapshot, just archive the guest private area and | |
204 | configuration files to the default dump directory (usually | |
205 | '/var/lib/vz/dump/'). | |
206 | ||
207 | # vzdump 777 | |
208 | ||
209 | Use rsync and suspend/resume to create a snapshot (minimal downtime). | |
210 | ||
211 | # vzdump 777 --mode suspend | |
212 | ||
213 | Backup all guest systems and send notification mails to root and admin. | |
214 | ||
215 | # vzdump --all --mode suspend --mailto root --mailto admin | |
216 | ||
217 | Use snapshot mode (no downtime) and non-default dump directory. | |
218 | ||
219 | # vzdump 777 --dumpdir /mnt/backup --mode snapshot | |
220 | ||
221 | Backup more than one guest (selectively) | |
222 | ||
223 | # vzdump 101 102 103 --mailto root | |
224 | ||
225 | Backup all guests excluding 101 and 102 | |
226 | ||
227 | # vzdump --mode suspend --exclude 101,102 | |
228 | ||
229 | Restore a container to a new CT 600 | |
230 | ||
231 | # pct restore 600 /mnt/backup/vzdump-lxc-777.tar | |
232 | ||
233 | Restore a QemuServer VM to VM 601 | |
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 |