25 lines
531 B
Bash
Executable file
25 lines
531 B
Bash
Executable file
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
umask 027
|
|
|
|
DESTDIR="/srv/backup"
|
|
DATE="$(date +%Y-%m-%d)"
|
|
|
|
cd "$DESTDIR"
|
|
find . -xdev -mindepth 2 -maxdepth 2 -type f -mtime +30 \
|
|
-execdir rm -f -- {} \;
|
|
find . -xdev -depth -mindepth 1 -maxdepth 1 -type d -empty \
|
|
-execdir rmdir -- {} \;
|
|
|
|
mkdir "$DATE"
|
|
|
|
for db in $(mysql -e "show databases" -s) ; do
|
|
case "$db" in
|
|
Database|information_schema|performance_schema)
|
|
continue
|
|
;;
|
|
esac
|
|
mysqldump -E --add-drop-table "$db" | gzip > "${DATE}/${db}.${DATE}.gz"
|
|
done
|