|
Lines 39-51
$scriptname
Link Here
|
| 39 |
|
39 |
|
| 40 |
This script dumps your Koha instance data for backup or migration. |
40 |
This script dumps your Koha instance data for backup or migration. |
| 41 |
|
41 |
|
|
|
42 |
The schema only option can be used to compare your existing database schema |
| 43 |
to the expected Koha structure. |
| 44 |
|
| 42 |
Usage: |
45 |
Usage: |
| 43 |
$scriptname [--quiet|-q] [--exclude-indexes] instancename1 [instancename2...] |
46 |
$scriptname [--quiet|-q] [--exclude-indexes] instancename1 [instancename2...] |
| 44 |
$scriptname -h|--help |
47 |
$scriptname -h|--help |
| 45 |
|
48 |
|
| 46 |
--exclude-indexes Include Zebra indexes on the backup. |
49 |
--schema-only Dump only the database schema |
|
|
50 |
--exclude-indexes Include Zebra indexes on the backup |
| 47 |
--quiet|-q Make the script avoid printing to STDOUT |
51 |
--quiet|-q Make the script avoid printing to STDOUT |
| 48 |
(useful for calling from another scripts). |
52 |
(useful for calling from another scripts) |
| 49 |
--help|-h Display this help message |
53 |
--help|-h Display this help message |
| 50 |
--without-db-name Do not include database name |
54 |
--without-db-name Do not include database name |
| 51 |
|
55 |
|
|
Lines 69-112
dump_instance()
Link Here
|
| 69 |
backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' $kohaconfig || true )" |
73 |
backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' $kohaconfig || true )" |
| 70 |
[ -z "$backupdir" ] && backupdir="/var/spool/koha/$name" |
74 |
[ -z "$backupdir" ] && backupdir="/var/spool/koha/$name" |
| 71 |
dbdump="$backupdir/$name-$date.sql.gz" |
75 |
dbdump="$backupdir/$name-$date.sql.gz" |
| 72 |
[ "$quiet" = "no" ] && echo "* DB to $dbdump" |
|
|
| 73 |
dbflag="--databases" |
| 74 |
[ "$without_db_name" = "yes" ] && dbflag="" |
76 |
[ "$without_db_name" = "yes" ] && dbflag="" |
| 75 |
mysqldump $dbflag --host="$mysqlhost" \ |
77 |
if [ "$schema_only" = "yes" ] |
| 76 |
--user="$mysqluser" --password="$mysqlpass" "$mysqldb" | |
78 |
then |
| 77 |
gzip > "$dbdump" |
79 |
schemadump="$backupdir/$name-schema-$date.sql" |
| 78 |
chown "root:$name-koha" "$dbdump" |
80 |
[ "$quiet" = "no" ] && echo "* schema to $schemadump" |
| 79 |
chmod g+r "$dbdump" |
81 |
mysqldump $dbflag -d --host="$mysqlhost" \ |
| 80 |
|
82 |
--user="$mysqluser" --password="$mysqlpass" "$mysqldb" > "$schemadump" |
| 81 |
instancefile="$name.conf" |
83 |
chown "root:$name-koha" "$dbdump" |
|
|
84 |
chmod g+r "$dbdump" |
| 85 |
else |
| 86 |
[ "$quiet" = "no" ] && echo "* DB to $dbdump" |
| 87 |
mysqldump $dbflag --host="$mysqlhost" \ |
| 88 |
--user="$mysqluser" --password="$mysqlpass" "$mysqldb" | |
| 89 |
gzip > "$dbdump" |
| 90 |
chown "root:$name-koha" "$dbdump" |
| 91 |
chmod g+r "$dbdump" |
| 92 |
|
| 93 |
instancefile="$name.conf" |
| 94 |
|
| 95 |
# Dump configs, logs, etc. |
| 96 |
metadump="$backupdir/$name-$date.tar.gz" |
| 97 |
[ "$quiet" = "no" ] && echo "* configs, logs to $metadump" |
| 98 |
|
| 99 |
if [ "$exclude_indexes" = "yes" ]; then |
| 100 |
excludes="--exclude=var/lib/koha/$name/biblios \ |
| 101 |
--exclude=var/lib/koha/$name/authorities" |
| 102 |
fi |
| 82 |
|
103 |
|
| 83 |
# Dump configs, logs, etc. |
104 |
tar -czf "$metadump" -C / $excludes \ |
| 84 |
metadump="$backupdir/$name-$date.tar.gz" |
105 |
"etc/koha/sites/$name" \ |
| 85 |
[ "$quiet" = "no" ] && echo "* configs, logs to $metadump" |
106 |
"etc/apache2/sites-available/$instancefile" \ |
|
|
107 |
"etc/apache2/sites-enabled/$instancefile" \ |
| 108 |
"var/lib/koha/$name" \ |
| 109 |
"var/log/koha/$name" |
| 86 |
|
110 |
|
| 87 |
if [ "$exclude_indexes" = "yes" ]; then |
111 |
[ "$quiet" = "no" ] && echo "Done." |
| 88 |
excludes="--exclude=var/lib/koha/$name/biblios \ |
|
|
| 89 |
--exclude=var/lib/koha/$name/authorities" |
| 90 |
fi |
112 |
fi |
| 91 |
|
|
|
| 92 |
tar -czf "$metadump" -C / $excludes \ |
| 93 |
"etc/koha/sites/$name" \ |
| 94 |
"etc/apache2/sites-available/$instancefile" \ |
| 95 |
"etc/apache2/sites-enabled/$instancefile" \ |
| 96 |
"var/lib/koha/$name" \ |
| 97 |
"var/log/koha/$name" |
| 98 |
|
| 99 |
[ "$quiet" = "no" ] && echo "Done." |
| 100 |
} |
113 |
} |
| 101 |
|
114 |
|
| 102 |
# Default values |
115 |
# Default values |
| 103 |
quiet="no" |
116 |
quiet="no" |
| 104 |
exclude_indexes="no" |
117 |
exclude_indexes="no" |
| 105 |
without_db_name="no" |
118 |
without_db_name="no" |
|
|
119 |
schema_only="no" |
| 106 |
|
120 |
|
| 107 |
while [ $# -gt 0 ]; do |
121 |
while [ $# -gt 0 ]; do |
| 108 |
|
122 |
|
| 109 |
case "$1" in |
123 |
case "$1" in |
|
|
124 |
--schema-only) |
| 125 |
schema_only="yes" |
| 126 |
shift ;; |
| 110 |
--exclude-indexes) |
127 |
--exclude-indexes) |
| 111 |
exclude_indexes="yes" |
128 |
exclude_indexes="yes" |
| 112 |
shift ;; |
129 |
shift ;; |
| 113 |
- |
|
|