Mit Rsync über Netzwerk Datenbank dumpen

Alle weiteren Dienste, die nicht in die drei oberen Foren gehören.
Antworten
Benutzeravatar
weshalb
Beiträge: 1265
Registriert: 16.05.2012 14:19:49

Mit Rsync über Netzwerk Datenbank dumpen

Beitrag von weshalb » 31.10.2017 18:34:31

Hallo, ich frage mich, wie ich es am Besten anstelle, über Rsnapshot mittels Rsync eine Datenbank auf einem entfernten Rechner zu dumpen und damit zu sichern.

Entfernte Ordner sowie die Datenbank auf dem eigenen System zu sichern klappt bisher ja super. Man könnte zwar auf dem entfernten Rechner selbst mittels Script dumpen und den Ordner dann über das Netz wegsichern, doch geht das nicht auch etwas eleganter vom Backuprechner selbst aus?

DeletedUserReAsG

Re: Mit Rsync über Netzwerk Datenbank dumpen

Beitrag von DeletedUserReAsG » 31.10.2017 18:49:00

Ginge mit ssh, indem man das Programm mit der Option, direkt nach stdout zu schreiben, aufruft und lokal die rausfallenden Daten wegspeichert.

Colttt
Beiträge: 2983
Registriert: 16.10.2008 23:25:34
Wohnort: Brandenburg
Kontaktdaten:

Re: Mit Rsync über Netzwerk Datenbank dumpen

Beitrag von Colttt » 31.10.2017 19:17:09

Professionelle Backuplösungen(Bsp Bareos) bieten sowas an nennt sich meistens dann irgendwie pre/post backup job.
Debian-Nutzer :D

ZABBIX Certified Specialist

thoerb
Beiträge: 1677
Registriert: 01.08.2012 15:34:53
Lizenz eigener Beiträge: MIT Lizenz

Re: Mit Rsync über Netzwerk Datenbank dumpen

Beitrag von thoerb » 31.10.2017 19:50:25

weshalb hat geschrieben: ↑ zum Beitrag ↑
31.10.2017 18:34:31
Man könnte zwar auf dem entfernten Rechner selbst mittels Script dumpen und den Ordner dann über das Netz wegsichern, doch geht das nicht auch etwas eleganter vom Backuprechner selbst aus?
Genau so mache ich das, mit zwei zeitversetzten Cronjobs. Einer macht täglich einen Dump auf dem Quellrechner und der zweite Cronjob sichert alle Daten mir rsync auf den Zielrechner. Somit habe ich auch immer zwei Sicherungen von der Datenbank.

letzter3
Beiträge: 443
Registriert: 16.07.2011 22:07:31

Re: Mit Rsync über Netzwerk Datenbank dumpen

Beitrag von letzter3 » 31.10.2017 22:56:11

Meine Lösung:

Code: Alles auswählen

root@ptLWL01:~# tree /etc/automysqlbackup
/etc/automysqlbackup
├── automysqlbackup.conf
├── LICENSE
├── myserver.conf
├── mysql-backup-post
├── mysql-backup-pre
└── README
automysql backupt (?) und rotiert.

Code: Alles auswählen

root@ptLWL01:/etc/automysqlbackup# cat myserver.conf
CONFIG_mysql_dump_username='root'

# Password to access the MySQL server e.g. password
CONFIG_mysql_dump_password='password'

# Host name (or IP address) of MySQL server e.g localhost
CONFIG_mysql_dump_host='localhost'

# "Friendly" host name of MySQL server to be used in email log
# if unset or empty (default) will use CONFIG_mysql_dump_host instead
CONFIG_mysql_dump_host_friendly='ptlwl01-mysql-Server'

# Backup directory location e.g /backups
CONFIG_backup_dir='/home/backup'

# This is practically a moot point, since there is a fallback to the compression
# functions without multicore support in the case that the multicore versions aren't
# present in the system. Of course, if you have the latter installed, but don't want
# to use them, just choose no here.
# pigz -> gzip
# pbzip2 -> bzip2
CONFIG_multicore='no'

# Number of threads (= occupied cores) you want to use. You should - for the sake
# of the stability of your system - not choose more than (#number of cores - 1).
# Especially if the script is run in background by cron and the rest of your system
# has already heavy load, setting this too high, might crash your system. Assuming
# all systems have at least some sort of HyperThreading, the default is 2 threads.
# If you wish to let pigz and pbzip2 autodetect or use their standards, set it to
# 'auto'.
#CONFIG_multicore_threads=auto

# Databases to backup

# List of databases for Daily/Weekly Backup e.g. ( 'DB1' 'DB2' 'DB3' ... )
# set to (), i.e. empty, if you want to backup all databases
CONFIG_db_names=('ptlwl' 'ingutenhaenden')
# You can use
#declare -a MDBNAMES=( "${DBNAMES[@]}" 'added entry1' 'added entry2' ... )
# INSTEAD to copy the contents of $DBNAMES and add further entries (optional).

# List of databases for Monthly Backups.
# set to (), i.e. empty, if you want to backup all databases
CONFIG_db_month_names=('ptlwl' 'ingutenhaenden')

# List of DBNAMES to EXLUCDE if DBNAMES is empty, i.e. ().
#CONFIG_db_exclude=( 'information_schema' )

# List of tables to exclude, in the form db_name.table_name
# You may use wildcards for the table names, i.e. 'mydb.a*' selects all tables starting with an 'a'.
# However we only offer the wildcard '*', matching everything that could appear, which translates to the
# '%' wildcard in mysql.
#CONFIG_table_exclude=()


# Advanced Settings

# Rotation Settings

# Which day do you want monthly backups? (01 to 31)
# If the chosen day is greater than the last day of the month, it will be done
# on the last day of the month.
# Set to 0 to disable monthly backups.
CONFIG_do_monthly="1"

# Which day do you want weekly backups? (1 to 7 where 1 is Monday)
# Set to 0 to disable weekly backups.
CONFIG_do_weekly="0"

# Set rotation of daily backups. VALUE*24hours
# If you want to keep only today's backups, you could choose 1, i.e. everything older than 24hours will be removed.
CONFIG_rotation_daily=4

# Set rotation for weekly backups. VALUE*24hours
CONFIG_rotation_weekly=24

# Set rotation for monthly backups. VALUE*24hours
CONFIG_rotation_monthly=4


# Server Connection Settings

# Set the port for the mysql connection
CONFIG_mysql_dump_port=3306

# Compress communications between backup server and MySQL server?
#CONFIG_mysql_dump_commcomp='no'

# Use ssl encryption with mysqldump?
#CONFIG_mysql_dump_usessl='yes'

# For connections to localhost. Sometimes the Unix socket file must be specified.
#CONFIG_mysql_dump_socket=''

# The maximum size of the buffer for client/server communication. e.g. 16MB (maximum is 1GB)
#CONFIG_mysql_dump_max_allowed_packet=''


# Include CREATE DATABASE in backup?
CONFIG_mysql_dump_create_database='yes'

# Separate backup directory and file for each DB? (yes or no)
CONFIG_mysql_dump_use_separate_dirs='yes'

# Choose Compression type. (gzip or bzip2)
CONFIG_mysql_dump_compression='bzip2'

# Notification setup

# What would you like to be mailed to you?
# - log   : send only log file
# - files : send log file and sql files as attachments (see docs)
# - stdout : will simply output the log to the screen if run manually.
# - quiet : Only send logs if an error occurs to the MAILADDR.
CONFIG_mailcontent='quiet'

# Email Address to send mail to? (user@domain.com)
CONFIG_mail_address='letzter'


# Encryption

# Do you wish to encrypt your backups using openssl?
CONFIG_encrypt='no'


# Command to run before backups (uncomment to use)
CONFIG_prebackup="/etc/automysqlbackup/mysql-backup-pre"

# Command run after backups (uncomment to use)
CONFIG_postbackup="/etc/automysqlbackup/mysql-backup-post"

root@ptLWL01:/etc/automysqlbackup# 
vorher wird der externe Rechner eingebunden

Code: Alles auswählen

root@ptLWL01:/etc/automysqlbackup# cat mysql-backup-pre
#!/bin/sh
[ -z "$(mount | grep /mnt/webdav)" ] && echo "USER\nPASSWORD"|mount -t davfs https://USER.webdav.hidrive.strato.com /mnt/webdav.USER
Danach wird mittels rsync syncronisiert

Code: Alles auswählen

root@ptLWL01:/etc/automysqlbackup# cat mysql-backup-post
#!/bin/sh

rsync --delete --size-only -ar /home/backup/ /mnt/webdav.USER/users/USER/backup && umount.davfs /mnt/webdav.USER 


uname
Beiträge: 12045
Registriert: 03.06.2008 09:33:02

Re: Mit Rsync über Netzwerk Datenbank dumpen

Beitrag von uname » 01.11.2017 07:51:46

Ich würde sicherheitshalber immer mehrere Backupgenerationen anlegen und diese natürlich von Zeit zu Zeit prüfen. Bei komprimierten Dateien kann man z.B. versuchen die Dateien zu entpacken. Sollte eigentlich bei rsync immer gehen (Bitprüfung) ... aber man weiß ja nie.

Benutzeravatar
weshalb
Beiträge: 1265
Registriert: 16.05.2012 14:19:49

Re: Mit Rsync über Netzwerk Datenbank dumpen

Beitrag von weshalb » 01.11.2017 11:07:17

Danke für die vielen Hinweise. Ich habe das jetzt tatäschlich so gelöst, dass ich auf der entfernten Maschine mittles Rsnapshot und Backupscript lediglich die Datenbank dumpe und das zeitversetzt zu meinem Cron mache.

Die restlichen Daten backupe ich mittels Rsync von dem Backupserver aus, da das über Rsnapshot auf dem entfernten Server nicht nur etwas doppelt gemoppelt sein würde, sondern so schließe ich von vornherein auch aus, dass sich bei großen Datenmengen sich da zeitlich nichts überlagert.

Antworten