]> git.proxmox.com Git - pmg-docs.git/blame - pmgbackup.adoc
add short documentation on PBS backups
[pmg-docs.git] / pmgbackup.adoc
CommitLineData
aebeb2f5
DM
1[[chapter_pmgbackup]]
2ifdef::manvolnum[]
3pmgbackup(1)
4============
5:pmg-toplevel:
6
7NAME
8----
9
10pmgbackup - Proxmox Mail Gateway Backup and Restore Utility
11
12
13SYNOPSIS
14--------
15
16include::pmgbackup.1-synopsis.adoc[]
17
18DESCRIPTION
19-----------
20endif::manvolnum[]
21ifndef::manvolnum[]
22Backup and Restore
23==================
24:pmg-toplevel:
25endif::manvolnum[]
26
00a7fa74 27ifndef::manvolnum[]
a695a527 28[thumbnail="pmg-gui-backup.png", big=1]
00a7fa74
DM
29endif::manvolnum[]
30
31{pmg} includes the ability to backup and restore the
32configuration. This includes the complete config from `/etc/pmg/`, the
33mail filter rules and the statistic database.
34
35NOTE: The backup does not include the network setup, and also no mail
36data from the postfix queue or the spam or virus quarantine.
37
18734510
SI
38Backups can be created locally or stored on a
39https://www.proxmox.com/en/proxmox-backup-server[Proxmox Backup Server]
40instance.
41
42Local Backups
43-------------
44
45You can create a backup by simply pressing the 'Backup' button in the 'Local
46Backup/Restore' tab on the GUI, or by using the command line interface:
00a7fa74
DM
47
48----
49# pmgbackup backup
50starting backup to: /var/lib/pmg/backup/pmg-backup_2018_01_04_5A4E0436.tgz
51backup finished
52----
53
18734510 54Local backups are stored inside directory `/var/lib/pmg/backup/`. It is
00a7fa74
DM
55usually best to mount a remote file system to that directory, so that
56the resulting backups gets stored remotely.
57
58You can list the contents of that directory with:
59
60----
61# pmgbackup list
62....
63pmg-backup_2017_11_10_5A05D4B9.tgz 17012
64pmg-backup_2017_11_13_5A09676A.tgz 16831
65pmg-backup_2018_01_04_5A4E0436.tgz 21514
66----
67
68Restores are also possible using the GUI or command line, and you can
69select what parts you want to restore:
70
71System Configuration::
72
73Basically the contents of `/etc/pmg/`.
74
75Rule Database::
76
77The mail filter rule database.
78
79Statistic::
80
81All statistical data.
82
b86b6da3 83For example, you can selectively restore the mail filter rules from an
00a7fa74
DM
84older backup:
85
86----
87# pmgbackup restore --filename pmg-backup_2018_01_04_5A4E0436.tgz --database
88starting restore: /var/lib/pmg/backup/pmg-backup_2018_01_04_5A4E0436.tgz
89config_backup.tar: OK
90Proxmox_ruledb.sql: OK
91Proxmox_statdb.sql: OK
92version.txt: OK
93Destroy existing rule database
94Create new database
95run analyze to speed up database queries
96Analyzing/Upgrading existing Databases...done
97restore finished
98----
99
18734510
SI
100Proxmox Backup Server
101---------------------
102
103In order to backup your {pmg} configuration on a Proxmox Backup Server you
104need configure the instance as backup 'remote'. You can then directly create
105and restore backups, as well as create a scheduled 'backup job' to run
106regular backups.
107
108Remotes
109~~~~~~~
110
111ifndef::manvolnum[]
112[thumbnail="pmg-gui-pbs-remote.png", big=1]
113endif::manvolnum[]
114
115A Proxmox Backup Server remote can be configured using the 'Proxmox Backup
116Server' panel in the 'Backup/Restore' menu of the GUI, or by using the
117`remote` subcommand of `pmgbackup`:
118
119----
120# pmgbackup remote add backup --datastore big --server backup.proxmox.com --user 'pmgbackup@pbs!token' --password --fingerprint 09:54:ef:..snip..:88:af:47:fe:4c:3b:cf:8b:26:88:0b:4e:3c:b2
121Enter new password: ******
122Retype new password: ******
123----
124
125You can use API Tokens in place of a username/password combination.
126
127If the remote certificate is signed by a CA trusted by {pmg} the fingerprint
128is not required.
129
130Additionally you can configure `prune-settings` for each remote to control
131how many backups should be stored on the Proxmox Backup Server:
132
133----
134# pmgbackup remote set backup --keep-last 5 --keep-daily 30 --keep-yearly 5
135----
136The backup-group is pruned after each successful backup according to the
137configured settings.
138
139The public settings are stored in `/etc/pmg/pbs/pbs.conf`, sensitive settings,
140like passwords are stored in individual files named after the remote inside
141`/etc/pmg/pbs/`:
142
143.Configuration Example (`/etc/pmg/pbs/pbs.conf`)
144----
145pbs: backup
146 datastore big
147 server backup.proxmox.com
148 fingerprint 09:54:ef:..snip..:88:af:47:fe:4c:3b:cf:8b:26:88:0b:4e:3c:b2
149 keep-daily 30
150 keep-last 5
151 keep-monthly 3
152 keep-yearly 5
153 username pmgbackup@pbs!token
154----
155
156Backup Jobs
157~~~~~~~~~~~
158
159With a configured remote you can create backups using the GUI or the
160`pbsjob` subcommand of `pmgbackup`:
161
162----
163# pmgbackup pbsjob run backup
164starting update of current backup state
165Starting backup: host/pmg/2020-11-16T16:38:39Z
166Client name: pmg
167Starting backup protocol: Mon Nov 16 16:38:39 2020
168Upload directory '/var/lib/pmg/backup/current' to 'pmgbackup@pbs!token@backup.proxmox.com:8007:local' as pmgbackup.pxar.didx
169pmgbackup.pxar: had to upload 188.33 KiB of 188.33 KiB in 0.00s, average speed 162.33 MiB/s).
170Uploaded backup catalog (145 B)
171Duration: 0.06s
172End Time: Mon Nov 16 16:38:39 2020
173backup finished
174starting prune of host/pmg
175prune finished
176----
177
178For restoring you can optionally select a particular backup-snapshot to return
179to the state of configuration and rules at that time. If you don't provide one
180the latest backup is restored:
181
182----
183# pmgbackup pbsjob restore backup --backup-time 2020-11-16T14:03:04Z
184starting restore of host/pmg/2020-11-16T14:03:04Z from backup
185..snip..
186restore finished
187----
188
189You can mark a particular snapshot for garbage collection by Proxmox Backup
190Server, by forgetting it:
191
192----
193# pmgbackup pbsjob forget backup 2020-11-16T14:03:04Z
194----
195
196Scheduled Backups
197^^^^^^^^^^^^^^^^^
198
199You can create a `Schedule` for each remote, to periodically create backups of
200your {pmg} - for example to run a daily backup at 03:50:00 with a randomized
201delay of 15 minutes each day:
202
203----
204# pmgbackup pbsjob create backup --schedule '*-*-* 03:50:00' --delay '15 minutes'
205----
206
207The randomized delay can help to prevent load-peaks on the backup server, if
208you have multiple backups, which all should start around the same time.
00a7fa74 209
18734510
SI
210The schedules are `systemd.timer` units. See the `systemd.time(7)` man page for
211details on the time specification used.
aebeb2f5
DM
212
213
214ifdef::manvolnum[]
215include::pmg-copyright.adoc[]
216endif::manvolnum[]
217