690 shaares
3 liens privés
3 liens privés
4 résultats
taggé
dump
Exploration d'objet dans un dump mémoire via MAT
Exemple :
SELECT * FROM java.lang.String s WHERE toString(s) LIKE ".*day"
SELECT * FROM "java\.lang\..*"
Liste des threads avec id et name
SELECT t.tid, toString(t.name), t FROM INSTANCEOF java.lang.Thread t
Liste des attributs statiques d'une classe : dans le dominator tree then list outgoing elements
class.*my.package.my.class.*
Script backups des bases de données mysql - Documentation publique - Gestionnaire de projets Redmine
Le script + Delete des sauvegardes
#! /bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_BASE="/home/mariadb/backup"
BACKUP_DIR="$BACKUP_BASE/$TIMESTAMP"
MYSQL_USER="BACKUPUSER"
MYSQL="mysql $1"
MYSQL_PASSWORD="PASSWORD"
MYSQLDUMP="mysqldump $1"
FAILED=0
function makeBackup() {
rm -rf "$BACKUP_DIR"
mkdir -p "$BACKUP_DIR"
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`
for db in $databases; do
echo $(date +"%Y-%m-%d %H:%M:%S")" saving $db..."
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/$db.gz"
EXITCODE=$?
if [ $EXITCODE -ne 0 ] ; then
MESSAGE="$db failed with exit code $EXITCODE"
FAILED=1
else
MESSAGE="$db saved ok"
fi
echo $(date +"%Y-%m-%d %H:%M:%S")" $MESSAGE"
done
}
function deleteBackup() {
if [ $FAILED -eq 0 ] ; then
echo "Clean backup directory $BACKUP_BASE"
cd $BACKUP_BASE
echo "Backup that will be deleted :"
(ls -t |head -n 20;ls)|sort|uniq -u
(ls -t |head -n 20;ls)|sort|uniq -u|xargs rm -rf
echo "Clean done"
else
echo "No clean done, some database failed"
fi
}
makeBackup
deleteBackup
Creation et droit du user :
GRANT LOCK TABLES, SELECT ON *.* TO 'BACKUPUSER'@'%' IDENTIFIED BY 'PASSWORD';
flush privileges;
bye;
Et ensuite :
mysqldump -u BACKUPUSER -pPASSWORD --all-databases > all-database.sql
Single base
# backup
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
# restore
mysql -u root -p[root_password] [database_name] < dumpfilename.sql
All bases :
# backup
mysqldump -u root -ptmppassword --all-databases > /tmp/all-database.sql
# restore
mysql -u root -p[root_password] < dumpfilename.sql
!!! Les schémas doivent être vides avant le restore !!!