]> git.proxmox.com Git - pve-docs.git/blob - vzdump.adoc
rewrite backup mode explaination for qemu
[pve-docs.git] / vzdump.adoc
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 Backup modes
52 ------------
53 There are several ways to provide consistency (option `mode`),
54 depending on the guest type.
55
56 .Backup modes for VMs:
57
58 `stop` mode::
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.
64
65 `suspend` mode::
66
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.
71
72 `snapshot` mode::
73
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.
80
81 A technical overview of the Proxmox VE live backup for QemuServer can
82 be found online
83 https://git.proxmox.com/?p=pve-qemu-kvm.git;a=blob;f=backup.txt[here].
84
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.
88
89 .Backup modes for Containers:
90
91 `stop` mode::
92
93 Stop the container for the duration of the backup. This potentially results in
94 a very long downtime.
95
96 `suspend` mode::
97
98 This mode uses rsync to copy the container data to a temporary
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)
101 again. This results in minimal downtime, but needs additional space
102 to hold the container copy.
103 +
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.
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.
109
110 `snapshot` mode::
111
112 This mode uses the snapshotting facilities of the underlying
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).
121
122 NOTE: bind and device mountpoints are skipped during backup operations, like
123 volume mountpoints with the backup option disabled.
124
125
126 Backup File Names
127 -----------------
128
129 Newer versions of vzdump encode the guest type and the
130 backup time into the filename, for example
131
132 vzdump-lxc-105-2009_10_09-11_04_43.tar
133
134 That way it is possible to store several backup in the same
135 directory. The parameter `maxfiles` can be used to specify the
136 maximum number of backups to keep.
137
138 Restore
139 -------
140
141 The resulting archive files can be restored with the following programs.
142
143
144 `pct restore`:: Container restore utility
145
146 `qmrestore`:: QemuServer restore utility
147
148 For details see the corresponding manual pages.
149
150 Configuration
151 -------------
152
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 '#'
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.
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 ----
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
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`)
192
193 /tmp/?*
194 /var/tmp/?*
195 /var/run/?*pid
196
197 You can also manually specify (additional) exclude paths, for example:
198
199 # vzdump 777 --exclude-path /tmp/ --exclude-path '/var/foo*'
200
201 (only excludes tmp directories)
202
203 Configuration files are also stored inside the backup archive
204 (in `./etc/vzdump/`) and will be correctly restored.
205
206 Examples
207 --------
208
209 Simply dump guest 777 - no snapshot, just archive the guest private area and
210 configuration files to the default dump directory (usually
211 '/var/lib/vz/dump/').
212
213 # vzdump 777
214
215 Use rsync and suspend/resume to create a snapshot (minimal downtime).
216
217 # vzdump 777 --mode suspend
218
219 Backup all guest systems and send notification mails to root and admin.
220
221 # vzdump --all --mode suspend --mailto root --mailto admin
222
223 Use snapshot mode (no downtime) and non-default dump directory.
224
225 # vzdump 777 --dumpdir /mnt/backup --mode snapshot
226
227 Backup more than one guest (selectively)
228
229 # vzdump 101 102 103 --mailto root
230
231 Backup all guests excluding 101 and 102
232
233 # vzdump --mode suspend --exclude 101,102
234
235 Restore a container to a new CT 600
236
237 # pct restore 600 /mnt/backup/vzdump-lxc-777.tar
238
239 Restore a QemuServer VM to VM 601
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