Datenbanksicherung per cronjob
Datenbanksicherung per cronjob
Ich möchte nun endlich, was ich mir seit 3 Jahren vornehme :roll:, eine Datenbanksicherung per cronjob einrichten. Auf meinem Server läuft Plesk, über das ich die Cronjobs erstellen kann (siehe Bild 1):
http://www.wheatus.org/cronjob.jpg
Dort habe ich eingestellt, dass der cronjob täglich nachts um 02:00h durchgeführt werden soll.
In der backup.sh steht folgendes:
http://www.wheatus.org/cronjob-datei.jpg
Sollte doch funktionieren, oder? Leider nicht, hab ich was falsch gemacht?
http://www.wheatus.org/cronjob.jpg
Dort habe ich eingestellt, dass der cronjob täglich nachts um 02:00h durchgeführt werden soll.
In der backup.sh steht folgendes:
http://www.wheatus.org/cronjob-datei.jpg
Sollte doch funktionieren, oder? Leider nicht, hab ich was falsch gemacht?
Re: Datenbanksicherung per cronjob
Ist die Suche kaputt? :-)
Im Ernst - wenn Du schon Hilfe bei Scripten möchtest, poste sie bitte - keiner wird das abtippen und korrigieren.
flo.
Im Ernst - wenn Du schon Hilfe bei Scripten möchtest, poste sie bitte - keiner wird das abtippen und korrigieren.
flo.
Re: Datenbanksicherung per cronjob
Sorry ;)
Könnte daran was falsch sein?
Code: Select all
#!/bin/sh
DIR=`/xxx/httpdocs/backup/`
DATUM=`date ‘+%d-%m-%Y’`
mysqldump -uxxx -pxxx -hlocalhost xxx > $DIR/backup.sql
gzip -9 –best $DIR/backup.sql
mv $DIR/backup.sql $DIR/backup-${DATUM}.sql.gz
find $DIR/backup.sql -name *.sql.gz -mtime +5 -exec rm {} ;
Re: Datenbanksicherung per cronjob
Manpages lesen und Pfade/Optionen selbst anpassen:
Code: Select all
#!/bin/bash
DIR="/xxx/httpdocs/backup/"
DATUM=`/bin/date '+%d-%m-%Y'`
/usr/bin/mysqldump -uxxx -pxxx -hlocalhost xxx > $DIR/backup.sql
/bin/gzip $DIR/backup.sql
/bin/mv $DIR/backup.sql $DIR/backup-${DATUM}.sql.gz
/bin/find $DIR/ -name *.sql.gz -mtime +5 -exec /bin/rm {} ;
exit 0
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Re: Datenbanksicherung per cronjob
Code: Select all
#!/bin/bash
DIR="/xxx/httpdocs/backup/"
DATUM=`/bin/date '+%d-%m-%Y'`
cd $DIR || exit 1
/usr/bin/mysqldump -uxxx -pxxx -hlocalhost xxx | gzip > backup-${DATUM}.sql.gz
/bin/find . -name *.sql.gz -mtime +5 -exec /bin/rm {} ;
exit 0
Re: Datenbanksicherung per cronjob
Code: Select all
[root@xxx]# ./backup.sh
-bash: ./backup.sh: Permission denied
Re: Datenbanksicherung per cronjob
chmod +x gemacht? Oder vielleihct doch lieber ein chmod 0700 auf die Datei? :twisted:
Re: Datenbanksicherung per cronjob
Hab die Rechte nun angepasst, hatte ich ganz vergessen, mache es nun auch nicht mehr über root. Allerdings bekomme ich nun folgendes:
Code: Select all
[userxxx@kekzdose ~]$ ./backup.sh
: No such file or directory
Re: Datenbanksicherung per cronjob
Pfade angepasst?
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Re: Datenbanksicherung per cronjob
Leere Zeile am Anfang? :-)
Re: Datenbanksicherung per cronjob
Gentoo Linux:
Code: Select all
#!/bin/sh
/usr/bin/mysqldump --flush-logs --master-data --lock-all-tables --opt --delete-master-logs --all-databases -uDbUsEr -pDbPaSs > /backup/mysqldump_`date +%Y%m%d%H`.sql
/usr/bin/mysqlcheck --analyze --check --auto-repair --extend --optimize --all-databases -uDbUsEr -pDbPaSs
/usr/bin/find /backup/ -type f -name *.sql -mtime +7 -print0 | /usr/bin/xargs -0 /bin/rm -f
exit 0
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Re: Datenbanksicherung per cronjob
Problem ist, dass ich die Pfade nicht weiß :(
Re: Datenbanksicherung per cronjob
Code: Select all
man which
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.