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