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