crufty scripts to manage gitea database

master
debian 3 years ago
parent 8d80662101
commit 16707874a9
  1. 4
      scripts/spacecruft-mysql
  2. 18
      scripts/spacecruft-mysql-backup
  3. 10
      scripts/spacecruft-mysql-mirror-no-wiki-issues

@ -0,0 +1,4 @@
#!/bin/bash
mysql -h `cat /root/.mysqlhost` -u `cat /root/.mysqluser` -p`cat /root/.mysqlpw` `cat /root/.mysqldb`

@ -0,0 +1,18 @@
#!/bin/bash
BACKUPDIR=/var/lib/dbbackup
NOW=`date +%Y%m%d%H%M`
mkdir -p $BACKUPDIR
chown root:root $BACKUPDIR
chmod og-rwx $BACKUPDIR
touch $BACKUPDIR/mysqldump-$NOW.sql
chmod 400 $BACKUPDIR/mysqldump-$NOW.sql
# Backup full DB
sudo nice mysqldump -p -u `cat /root/.mysqluser` -h `cat /root/.mysqlhost` -p`cat /root/.mysqlpw` `cat /root/.mysqldb` > $BACKUPDIR/mysqldump-$NOW.sql
# Compress it
nice xz $BACKUPDIR/mysqldump-$NOW.sql

@ -0,0 +1,10 @@
#!/bin/bash
# This script disables Issues and Wiki for repositories that are mirrors.
for i in \
`echo "SELECT repo_id FROM mirror" | /root/spacecruft-mysql | grep -v "repo_id"`
do echo "Repo ID: $i"
echo "DELETE FROM repo_unit WHERE repo_id=$i AND type=2;" | /root/spacecruft-mysql
echo "DELETE FROM repo_unit WHERE repo_id=$i AND type=5;" | /root/spacecruft-mysql
done
Loading…
Cancel
Save