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