]> git.uio.no Git - usit-rt.git/blame - docs/backups.pod
Master to 4.2.8
[usit-rt.git] / docs / backups.pod
CommitLineData
45030404
MKG
1=head1 BACKUPS
2
3RT is often a critical piece of businesses and organizations. Backups are
4absolutely necessary to ensure you can recover quickly from an incident.
5
6Make sure you take backups. Make sure they I<work>.
7
8There are many issues that can cause broken backups, such as a
c33a4027 9C<max_allowed_packet> too low for MySQL (in either the client or server), or
45030404
MKG
10encoding issues, or running out of disk space.
11
12Make sure your backup cronjobs notify someone if they fail instead of failing
13silently until you need them.
14
15Test your backups regularly to discover any unknown problems B<before> they
16become an issue. You don't want to discover problems with your backups while
17tensely restoring from them in a critical data loss situation.
18
19=head2 DATABASE
20
21You should backup the entire RT database, although for improved speed and space
22you can ignore the I<data> in the C<sessions> table. Make sure you still get
23the C<sessions> schema, however.
24
25Database specific notes and example backup commands for each database are
26below. Adjust the commands as necessary for connection details such as
27database name (C<rt4> is the placeholder below), user, password, host, etc.
28You should put the example commands into a shell script for backup and setup a
29cronjob. Make sure output from cron goes to someone who reads mail! (Or into
30RT. :)
31
32=head3 MySQL
33
c33a4027 34 ( mysqldump rt4 --tables sessions --no-data --single-transaction; \
45030404 35 mysqldump rt4 --ignore-table rt4.sessions --single-transaction ) \
01e3b242 36 | gzip > rt-`date +%Y%m%d`.sql.gz
45030404 37
45030404
MKG
38The dump will be much faster if you can connect to the MySQL server over
39localhost. This will use a local socket instead of the network.
40
41If you find your backups taking far far too long to complete (this point should
42take quite a long time to get to on an RT database), there are some alternate
43solutions. Percona maintains a highly regarded hot-backup tool for MySQL
44called L<XtraBackup|http://www.percona.com/software/percona-xtrabackup/>. If
45you have more resources, you can also setup replication to a slave using binary
46logs and backup from there as necessary. This not only duplicates the data,
47but lets you take backups without putting load on your production server.
48
49=head3 PostgreSQL
50
51 ( pg_dump rt4 --table=sessions --schema-only; \
52 pg_dump rt4 --exclude-table=sessions ) \
01e3b242 53 | gzip > rt-`date +%Y%m%d`.sql.gz
45030404
MKG
54
55=head2 FILESYSTEM
56
57You will want to back up, at the very least, the following directories and files:
58
59=over 4
60
61=item /opt/rt4
62
63RT's source code, configuration, GPG data, and plugins. Your install location
64may be different, of course.
65
66You can omit F<var/mason_data> and F<var/session_data> if you'd like since
67those are temporary caches. Don't omit all of F<var/> however as it may
68contain important GPG data.
69
70=item Webserver configuration
71
72Often F</etc/httpd> or F</etc/apache2>. This will depend on your OS, web
73server, and internal configuration standards.
74
75=item /etc/aliases
76
77Your incoming mail aliases mapping addresses to queues.
78
79=item Mail server configuration
80
81If you're running an MTA like Postfix, Exim, SendMail, or qmail, you'll want to
82backup their configuration files to minimize restore time. "Lightweight" mail
83handling programs like fetchmail, msmtp, and ssmtp will also have configuration
84files, although usually not as many nor as complex. You'll still want to back
85them up.
86
87The location of these files is highly dependent on what software you're using.
88
89=item Crontab containing RT's cronjobs
90
91This may be F</etc/crontab>, F</etc/cron.d/rt>, a user-specific crontab file
92(C<crontab -l $USER>), or some other file altogether. Even if you only have
93the default cronjobs in place, it's one less piece to forget during a restore.
94If you have custom L<< C<rt-crontool> >> invocations, you don't want to have to
95recreate those.
96
97=back
98
99Simply saving a tarball should be sufficient, with something like:
100
01e3b242 101 tar czvpf rt-backup-`date +%Y%m%d`.tar.gz /opt/rt4 /etc/aliases /etc/httpd ...
45030404
MKG
102
103Be sure to include all the directories and files you enumerated above!
104