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