]>
git.ipfire.org Git - ipfire-2.x.git/blob - config/backup/backup.pl
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 NOW
="$(date "+%Y-%m-%d-%H:%M")"
26 for file
in /var/ipfire
/backup/addons
/includes/*; do
27 if [ -f
"${file}" ]; then
40 while read -r file
; do
41 for file
in ${file
}; do
42 if [ -e
"${file}" ]; then
54 # Backup all addons first
56 for addon
in $(list_addons
); do
57 make_addon_backup
"${addon}"
60 tar cvzf
"${filename}" \
61 --exclude
-from
="/var/ipfire/backup/exclude" \
62 --exclude
-from
="/var/ipfire/backup/exclude.user" \
63 $(process_includes
"/var/ipfire/backup/include" "/var/ipfire/backup/include.user") \
72 tar xvzpf
"${filename}" -C
/
77 if [ -d
"/var/ipfire/outgoing" ]; then
80 for file
in /var/ipfire
/firewall/{config
,outgoing
} \
81 /var/ipfire
/fwhosts/custo
m{hosts,groups,networks}; do
83 chown nobody
:nobody
"${file}"
89 # Remove old configuration
90 rm
-rf
"/var/ipfire/outgoing"
94 if [ -d
"/var/ipfire/xtaccess" ]; then
95 : > /var/ipfire
/firewall/config
96 chown nobody
:nobody
"/var/ipfire/firewall/config"
101 # Remove old configuration
102 rm
-rf
"/var/ipfire/xtaccess"
106 if [ -d
"/var/ipfire/dmzholes" ] || [ -d
"/var/ipfire/portfw" ]; then
107 : > /var/ipfire
/firewall/config
108 chown nobody
:nobody
"/var/ipfire/firewall/config"
113 # Remove old configuration
114 rm
-rf
"/var/ipfire/dmzholes"
118 if [ -d
"/var/ipfire/portfw" ]; then
122 # Remove old configuration
123 rm
-rf
"/var/ipfire/portfw"
129 # Convert old OpenVPN CCD files (CN change, Core Update 75)
136 local filelist
=( /var/log/messages* /var
/log/*.log /var/log/**/*.log )
138 echo
"${filelist[@]}"
141 make_addon_backup
() {
145 if [ ! -f
"/var/ipfire/backup/addons/includes/${name}" ]; then
146 echo
"${name} does not have any backup includes" >&2
150 local filename
="/var/ipfire/backup/addons/backup/${name}.ipf"
152 tar cvzf
"${filename}" \
153 $(process_includes
"/var/ipfire/backup/addons/includes/${name}")
156 restore_addon_backup
() {
159 if [ -d
"/tmp/${name}.ipf" ]; then
160 mv
"/tmp/${name}.ipf" "/var/ipfire/backup/addons/backup/${name}.ipf"
163 tar xvzpf
"/var/ipfire/backup/addons/backup/${name}.ipf" -C
/
170 # Desired backup filename
171 local filename
="/var/ipfire/backup/${NOW}.ipf"
175 make_backup
"${filename}" $(find_logfiles
)
179 make_backup
"${filename}"
183 restore_backup
"/tmp/restore.ipf"
187 make_addon_backup
"$@"
191 restore_addon_backup
"${1/.ipf/}"
195 if make_backup
"${filename}"; then
196 /usr/local/bin/backupiso
"${NOW}" &
201 mkdir -p
/var/ipfire
/backup/addons
/{backup
,includes
}
205 process_includes
"/var/ipfire/backup/include" "/var/ipfire/backup/include.user"
208 /var/ipfire
/backup/*.ipf
|/var/ipfire
/backup/addon
s/backup/*.ipf|/var
/tmp/backupiso
/*.iso
)
213 echo
"${0}: [include|exclude|restore|addonbackup <addon>|restoreaddon <addon>|iso]" >&2