pouet.net/bin/dump_DDL

40 lines
1006 B
Bash
Executable File

#!/bin/sh
# Dump the pouet.net DDL into a SQL text file
# Needed by sed to not throw out some warnings
LANG=C
# Make sure we are in the good folder
if [ ! -f COPYING ]
then
echo "Launch me in the root folder"
exit 1
fi
echo "Dumping the current DDL..."
ssh pouet mysqldump --skip-lock-tables \
--no-data \
--result-file=pouet.sql \
pouet
echo "Downloading the DDL..."
scp pouet:pouet.sql .
echo "Cleaning up the DDL..."
# Remove any AUTO_INCREMENT option
sed -e 's/ AUTO_INCREMENT=[0-9]*//' -i '' pouet.sql
# Delete the last 2 lines (empty line + date of dump)
sed -e 'N;$!P;$!D;$d' -i '' pouet.sql
# Remove the MySQL client version header
sed -e '/-- MySQL dump .* Distrib .*, for .*/d' -i '' pouet.sql
# Remove the MySQL server version header
sed -e '/-- Server version.*/d' -i '' pouet.sql
# Remove the host/database iformation
sed -e '/-- Host:.*Database:.*/d' -i '' pouet.sql
echo "Dump of the DDL completed in pouet.sql"