]> git.proxmox.com Git - pmg-docs.git/blame - pmgbackup.adoc
backup: add anchors to pbs sections
[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
8faa93f4 100[[pmgbackup_pbs]]
18734510
SI
101Proxmox Backup Server
102---------------------
103
104In order to backup your {pmg} configuration on a Proxmox Backup Server you
105need configure the instance as backup 'remote'. You can then directly create
106and restore backups, as well as create a scheduled 'backup job' to run
107regular backups.
108
8faa93f4 109[[pmgbackup_pbs_remotes]]
18734510
SI
110Remotes
111~~~~~~~
112
113ifndef::manvolnum[]
c2763fd2 114[thumbnail="pmg-gui-pbs-remote.png"]
18734510
SI
115endif::manvolnum[]
116
c2763fd2 117
18734510
SI
118A Proxmox Backup Server remote can be configured using the 'Proxmox Backup
119Server' panel in the 'Backup/Restore' menu of the GUI, or by using the
c2763fd2
TL
120`remote` subcommand of `pmgbackup`.
121
122NOTE: You can use API Tokens in place of a username/password combination.
18734510 123
c2763fd2 124.Example addition of a Proxmox Backup Server remote with id 'archive'.
18734510 125----
c2763fd2 126# pmgbackup proxmox-backup remote add archive --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
18734510
SI
127Enter new password: ******
128Retype new password: ******
129----
130
c2763fd2
TL
131The fingerprint is optional, if the certificate of the Proxmox Backup Server
132remote is signed by a CA trusted by {pmg}.
18734510 133
c2763fd2
TL
134Additionally you can configure `prune-settings` for each remote, giving you
135flexible control about how many backups should be stored on the Proxmox Backup
136Server over a period of time.
18734510 137
c2763fd2 138.Setting the prune options for the Proxmox Backup Server remote with id 'archive'.
18734510 139----
c2763fd2 140# pmgbackup remote set archive --keep-last 3 --keep-daily 14 --keep-weekly 8 --keep-monthly 12 --keep-yearly 7
18734510 141----
c2763fd2 142
70808289 143If prune settings are configured, the backup-group of {pmg} is pruned
c2763fd2 144automatically after each successful backup.
18734510
SI
145
146The public settings are stored in `/etc/pmg/pbs/pbs.conf`, sensitive settings,
147like passwords are stored in individual files named after the remote inside
148`/etc/pmg/pbs/`:
149
150.Configuration Example (`/etc/pmg/pbs/pbs.conf`)
151----
c2763fd2 152pbs: archive
18734510
SI
153 datastore big
154 server backup.proxmox.com
155 fingerprint 09:54:ef:..snip..:88:af:47:fe:4c:3b:cf:8b:26:88:0b:4e:3c:b2
156 keep-daily 30
157 keep-last 5
158 keep-monthly 3
159 keep-yearly 5
160 username pmgbackup@pbs!token
161----
162
8faa93f4 163[[pmgbackup_pbs_jobs]]
18734510
SI
164Backup Jobs
165~~~~~~~~~~~
166
c2763fd2
TL
167ifndef::manvolnum[]
168[thumbnail="pmg-gui-pbs-backup.png", big=1]
169endif::manvolnum[]
170
18734510 171With a configured remote you can create backups using the GUI or the
c2763fd2 172`proxmox-backup backup` subcommand of the `pmgbackup` CLI tool.
18734510 173
c2763fd2 174.Creating a new backup on the Proxmox Backup Server remote with id 'archive'.
18734510 175----
c2763fd2 176# pmgbackup proxmox-backup backup archive
18734510
SI
177starting update of current backup state
178Starting backup: host/pmg/2020-11-16T16:38:39Z
179Client name: pmg
180Starting backup protocol: Mon Nov 16 16:38:39 2020
181Upload directory '/var/lib/pmg/backup/current' to 'pmgbackup@pbs!token@backup.proxmox.com:8007:local' as pmgbackup.pxar.didx
182pmgbackup.pxar: had to upload 188.33 KiB of 188.33 KiB in 0.00s, average speed 162.33 MiB/s).
183Uploaded backup catalog (145 B)
184Duration: 0.06s
185End Time: Mon Nov 16 16:38:39 2020
186backup finished
187starting prune of host/pmg
188prune finished
189----
190
191For restoring you can optionally select a particular backup-snapshot to return
c2763fd2
TL
192to the state of configuration and rules at that time.
193
194On the commandline you can get first a list of available backup snapshots using
195the `proxmox-backup list` subcommand:
196
197.Listing available backups from the Proxmox Backup Server remote with id 'archive'.
198----
199# pmgbackup proxmox-backup list archive
200┌────────────┬──────────────────────┬────────┐
201│ backup-id │ backup-time │ size │
202╞════════════╪══════════════════════╪════════╡
203│ pmg │ 2020-11-16T14:03:04Z │ 121910 │
204├────────────┼──────────────────────┼────────┤
205 ...
206└────────────┴──────────────────────┴────────┘
207----
18734510 208
c2763fd2 209.Restoring a specific backup snapshot
18734510 210----
c2763fd2 211# pmgbackup proxmox-backup restore archive pmg 2020-11-16T14:03:04Z
18734510
SI
212starting restore of host/pmg/2020-11-16T14:03:04Z from backup
213..snip..
214restore finished
215----
216
c2763fd2
TL
217You can remove a particular snapshot by using the `forget` sub command, this
218allows the Proxmox Backup Server to pick it up during garbage collection.
18734510
SI
219
220----
c2763fd2 221# pmgbackup proxmox-backup forget archive pmg 2020-11-16T14:03:04Z
18734510
SI
222----
223
70808289 224TIP: You can configure and access all backup related functionality on both,
c2763fd2
TL
225the web interface and the command line interface.
226
8faa93f4 227[[pmgbackup_pbs_schedule]]
18734510
SI
228Scheduled Backups
229^^^^^^^^^^^^^^^^^
230
231You can create a `Schedule` for each remote, to periodically create backups of
232your {pmg} - for example to run a daily backup at 03:50:00 with a randomized
233delay of 15 minutes each day:
234
235----
c2763fd2 236# pmgbackup proxmox-backup job create archive --schedule '*-*-* 03:50:00' --delay '15 minutes'
18734510
SI
237----
238
239The randomized delay can help to prevent load-peaks on the backup server, if
240you have multiple backups, which all should start around the same time.
00a7fa74 241
18734510
SI
242The schedules are `systemd.timer` units. See the `systemd.time(7)` man page for
243details on the time specification used.
aebeb2f5
DM
244
245
246ifdef::manvolnum[]
247include::pmg-copyright.adoc[]
248endif::manvolnum[]
249