Changes

Jump to navigation Jump to search
937 bytes added ,  15:04, 10 April 2019
m
Line 1: Line 1: −
= Wikimedia =
+
=HD dd=
 +
<source lang="bash">#!/bin/bash
 +
USAGE="./$(basename ${0}) UUID output_filename"
 +
 
 +
if [ -z "${1}" ]; then
 +
    echo ${USAGE}
 +
    exit
 +
fi
 +
if [ -z "${2}" ]; then
 +
    echo ${USAGE}
 +
    exit
 +
fi
 +
 
 +
 
 +
BACKUP_ROOT=/mnt/backup
 +
HD=$(blkid|grep $1|awk -F : '{print $1}')
 +
 
 +
ISO=${BACKUP_ROOT}/$(hostname)/$(date '+%Y/%m')/$2.iso
 +
 
 +
echo "dd if=${HD} of=${ISO} bs=1M"
 +
dd if=${HD} of=${ISO} bs=1M</source>
 +
 
 +
=MediaWiki=
 +
 
 +
== With database dump ==
 
First add the following line to LocalSetings.php
 
First add the following line to LocalSetings.php
 
  <nowiki>$wgReadOnly = 'Dumping Database, Access will be restored shortly';</nowiki>
 
  <nowiki>$wgReadOnly = 'Dumping Database, Access will be restored shortly';</nowiki>
 
Delete this line after the backup.<br />
 
Delete this line after the backup.<br />
 
The script should be in the MediaWiki installation (where your [[LocalSettings.php]] is stored as well).
 
The script should be in the MediaWiki installation (where your [[LocalSettings.php]] is stored as well).
== backup.sh ==
+
 
<nowiki>
+
==mediawiki_mysql_backup.sh==
 +
<source lang="bash">
 
#!/bin/bash
 
#!/bin/bash
FNAME=`date +%Y-%m-%d`
+
FNAME=TS=RHSWiki`date +%d-%m-%Y`
 
mysqldump --database DATABASE_NAME -u USERNAME -pPASSWORD --add-drop-table -B > ${FNAME}.sql
 
mysqldump --database DATABASE_NAME -u USERNAME -pPASSWORD --add-drop-table -B > ${FNAME}.sql
 
zip -r ./backup/${FNAME}.zip images/ ${FNAME}.sql LocalSettings.php extensions/
 
zip -r ./backup/${FNAME}.zip images/ ${FNAME}.sql LocalSettings.php extensions/
 
rm ${FNAME}.sql
 
rm ${FNAME}.sql
  </nowiki>
+
  </source>
 
Bonus (not required):
 
Bonus (not required):
<nowiki>
+
<source lang="bash">
 
# careful here .. if this fails you'll delete files from the current directory instead.
 
# careful here .. if this fails you'll delete files from the current directory instead.
 
# Some checking might be in order, especially if you run this script from somewhere else
 
# Some checking might be in order, especially if you run this script from somewhere else
Line 32: Line 57:  
file_count=`ls | wc -l`
 
file_count=`ls | wc -l`
 
done
 
done
  </nowiki>
+
  </source>
 +
 
 +
== With automysqlbackup ==
 +
<syntaxhighlight lang="bash">
 +
#!/bin/bash
 +
DATE=$(date  +"%Y-%d-%m")
 +
/usr/sbin/automysqlbackup
 +
rsync -avp /var/lib/automysqlbackup/daily/wikidb /root/wikibackup/tmp/
 +
rsync -avLp /var/www/mediawiki /root/wikibackup/tmp/
 +
cd /root/wikibackup/tmp/
 +
tar -czvf "/root/wikibackup/wikibackup-${DATE}.tar.gz" *
 +
mv "/root/wikibackup/wikibackup-${DATE}.tar.gz" /tmp/
 +
 
 +
</syntaxhighlight>[http://www.mediawiki.org/wiki/User:Flominator/Backup_MW Source]
 +
<br />

Navigation menu