View | Details | Raw Unified | Return to bug 26947
Collapse All | Expand All

(-)a/debian/scripts/koha-dump (-28 / +46 lines)
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-114 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" \
82
            --user="$mysqluser" --password="$mysqlpass" "$mysqldb" > "$schemadump"
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
80
103
81
    instancefile="$name.conf"
104
        tar -czf "$metadump" -C / $excludes \
105
            "etc/koha/sites/$name" \
106
            "etc/apache2/sites-available/$instancefile" \
107
            "etc/apache2/sites-enabled/$instancefile" \
108
            "var/lib/koha/$name" \
109
            "var/log/koha/$name"
82
110
83
    # Dump configs, logs, etc.
111
        chown "root:$name-koha" "$metadump"
84
    metadump="$backupdir/$name-$date.tar.gz"
112
        chmod g+r "$metadump"
85
    [ "$quiet" = "no" ] && echo "* configs, logs to $metadump"
86
113
87
    if [ "$exclude_indexes" = "yes" ]; then
114
        [ "$quiet" = "no" ] && echo "Done."
88
        excludes="--exclude=var/lib/koha/$name/biblios \
89
                  --exclude=var/lib/koha/$name/authorities"
90
    fi
91
115
92
    tar -czf "$metadump" -C / $excludes \
116
    fi
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
    chown "root:$name-koha" "$metadump"
99
    chmod g+r "$metadump"
100
101
    [ "$quiet" = "no" ] && echo "Done."
102
}
117
}
103
118
104
# Default values
119
# Default values
105
quiet="no"
120
quiet="no"
106
exclude_indexes="no"
121
exclude_indexes="no"
107
without_db_name="no"
122
without_db_name="no"
123
schema_only="no"
108
124
109
while [ $# -gt 0 ]; do
125
while [ $# -gt 0 ]; do
110
126
111
    case "$1" in
127
    case "$1" in
128
        --schema-only)
129
            schema_only="yes"
130
            shift ;;
112
        --exclude-indexes)
131
        --exclude-indexes)
113
            exclude_indexes="yes"
132
            exclude_indexes="yes"
114
            shift ;;
133
            shift ;;
115
- 

Return to bug 26947