Bug 36325: Add option to koha-run-backups/koha-dump, to exclude logs
Written patch to add flag to both koha-dump and koha-run-backups. Test plan: 1. do a sudo koha-dump and sudo koha-run-backups and check the contents of the .tar.gz backup in /var/spool/koha/instance/ and verify logs are in there 2. apply this patch 3. this time do sudo koha-dump --exclude-logs and sudo koha-run-backups --exclude-logs and check the contents of the .tar.gz backup in /var/spool/koha/instance and verify nothing from /var/log/koha is in there. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
e48df518e8
commit
c8bc861ec7
|
|
@ -2,17 +2,17 @@
|
|||
#
|
||||
# koha-dump: dump all contents and configs for a Koha site
|
||||
# Copyright 2010 Catalyst IT, Ltd
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ $scriptname -h|--help
|
|||
|
||||
--schema-only Dump only the database schema
|
||||
--exclude-indexes Include Zebra indexes on the backup
|
||||
--exclude-logs Exclude /var/log/koha/name from the backup
|
||||
--uploaded_files Include uploaded files.
|
||||
--uploaded_temp_files Include temporary uploaded files.
|
||||
--quiet|-q Make the script avoid printing to STDOUT
|
||||
|
|
@ -123,6 +124,18 @@ dump_instance()
|
|||
output="$output to $metadump"
|
||||
[ "$quiet" = "no" ] && echo "$output"
|
||||
|
||||
if [ "$exclude_logs" = "yes" ]; then
|
||||
tar -czf "$metadump" -C / $excludes \
|
||||
"etc/koha/sites/$name" \
|
||||
"etc/apache2/sites-available/$instancefile" \
|
||||
"etc/apache2/sites-enabled/$instancefile" \
|
||||
"var/lib/koha/$name" \
|
||||
$uploaded_files_dir \
|
||||
$uploaded_temp_files_dir
|
||||
|
||||
chown "root:$name-koha" "$metadump"
|
||||
chmod g+r "$metadump"
|
||||
else
|
||||
tar -czf "$metadump" -C / $excludes \
|
||||
"etc/koha/sites/$name" \
|
||||
"etc/apache2/sites-available/$instancefile" \
|
||||
|
|
@ -134,6 +147,7 @@ dump_instance()
|
|||
|
||||
chown "root:$name-koha" "$metadump"
|
||||
chmod g+r "$metadump"
|
||||
fi
|
||||
|
||||
[ "$quiet" = "no" ] && echo "Done."
|
||||
fi
|
||||
|
|
@ -144,6 +158,7 @@ quiet="no"
|
|||
exclude_indexes="no"
|
||||
without_db_name="no"
|
||||
schema_only="no"
|
||||
exclude_logs="no"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
|
||||
|
|
@ -154,6 +169,9 @@ while [ $# -gt 0 ]; do
|
|||
--exclude-indexes)
|
||||
exclude_indexes="yes"
|
||||
shift ;;
|
||||
--exclude-logs)
|
||||
exclude_logs="yes"
|
||||
shift ;;
|
||||
--without-db-name)
|
||||
without_db_name="yes"
|
||||
shift ;;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2010-2011 Catalyst IT, Ltd
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ EOH
|
|||
|
||||
exclude_indexes=""
|
||||
|
||||
CMD_LINE=`getopt -o h --long days:,output:,help,exclude-indexes -n 'koha-run-backups' -- "$@"`
|
||||
CMD_LINE=`getopt -o h --long days:,output:,help,exclude-indexes,exclude-logs -n 'koha-run-backups' -- "$@"`
|
||||
|
||||
if [ $? != 0 ] ; then show_help ; exit 1 ; fi
|
||||
|
||||
|
|
@ -55,6 +55,8 @@ while true ; do
|
|||
dirname=$2; shift 2 ;;
|
||||
--exclude-indexes)
|
||||
exclude_indexes='--exclude-indexes'; shift ;;
|
||||
--exclude-logs)
|
||||
exclude_logs='--exclude-logs'; shift ;;
|
||||
--) shift ; break ;;
|
||||
*) echo "Unknown error parsing the command line!" ; exit 1 ;;
|
||||
esac
|
||||
|
|
@ -67,7 +69,7 @@ fi
|
|||
|
||||
for name in $(koha-list --enabled | grep -Fxv demo)
|
||||
do
|
||||
if koha-dump ${exclude_indexes} "$name" > /dev/null; then
|
||||
if koha-dump ${exclude_indexes} ${exclude_logs} "$name" > /dev/null; then
|
||||
# Only delete old backups if dump script return success.
|
||||
|
||||
if [ -z "$dirname" ]; then
|
||||
|
|
@ -79,4 +81,3 @@ do
|
|||
find $backupdir -maxdepth 1 \( -mtime +$days -or -mtime $days \) -name $name-'[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].???'.gz \( -name \*.sql.gz -or -name \*.tar.gz \) -print0 | xargs -0 -r rm
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue