initial commit
This commit is contained in:
commit
70e2552ded
|
@ -0,0 +1,13 @@
|
||||||
|
NAME = backupdb
|
||||||
|
BINDIR = /usr/local/bin
|
||||||
|
BACKUPDIR = /var/lib/backupdb
|
||||||
|
|
||||||
|
install:
|
||||||
|
install --mode=755 $(NAME) $(BINDIR)
|
||||||
|
if [ ! -d $(BACKUPDIR) ]; then mkdir -p $(BACKUPDIR); fi
|
||||||
|
echo "0 2 * * * root $(BINDIR)/$(NAME)" >> /etc/crontab
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
if [ -f $(BINDIR)/$(NAME) ]; then rm $(BINDIR)/$(NAME); fi
|
||||||
|
if [ -d $(BACKUPDIR) ]; then rm -r $(BACKUPDIR); fi
|
||||||
|
sed -i '/$(NAME)/d' /etc/crontab
|
|
@ -0,0 +1,2 @@
|
||||||
|
Simple script to make a daily backup of all MariaDB/MySQL databases.
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
OUTPUT="/var/lib/backupdb"
|
||||||
|
|
||||||
|
cd $OUTPUT
|
||||||
|
|
||||||
|
databases=`mysql -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
|
||||||
|
|
||||||
|
for db in $databases; do
|
||||||
|
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != _* ]]; then
|
||||||
|
DUMP=$OUTPUT/`date +%Y%m%d`.$db.sql
|
||||||
|
echo "Dumping database: $db"
|
||||||
|
if [[ -f ${DUMP}.gz ]]; then rm ${DUMP}.gz; fi
|
||||||
|
mysqldump --databases $db > $DUMP
|
||||||
|
gzip $DUMP
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue