forked from stefanlasiewski/ForemanTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforeman-backup.sh
41 lines (26 loc) · 881 Bytes
/
foreman-backup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
# Backup The Foreman, following the advice at
# http://theforeman.org/manuals/1.7/index.html#5.5.1Backup
# Currently a very simple script.
# Temporary: Be verbose
#set -x
# If any command fails, stop this script.
set -e
ME=`basename $0`
main () {
DATE=$(date '+%Y%m%d.%H%M')
BACKUPDIR=/data/backups/backup-$DATE
mkdir $BACKUPDIR
chgrp postgres $BACKUPDIR
chmod g+w $BACKUPDIR
cd $BACKUPDIR
# Backup postgres database
su - postgres -c "pg_dump -Fc foreman > $BACKUPDIR/foreman.dump"
# Backup config ifles
tar --selinux -czf $BACKUPDIR/etc_foreman_dir.tar.gz /etc/foreman
tar --selinux -czf $BACKUPDIR/var_lib_puppet_dir.tar.gz /var/lib/puppet/ssl
tar --selinux -czf $BACKUPDIR/tftpboot-dhcp.tar.gz /var/lib/tftpboot /etc/dhcp/ /var/lib/dhcpd/
ls -lh *tar.gz foreman.dump
}
main 2>&1 | /usr/bin/logger -t $ME