DIY Linux Web Server HACK - Automate your MySQL MySQL database backups DIY Linux-Web-Server HACK - Automatisieren Sie Ihre MySQL-MySQL-Datenbank-Backups
Okay, I’ve been running dedicated servers for couple years now and I used to mess around with Linux boxes back in college. Okay, ich habe seit dedizierte Server für einige Jahre und jetzt habe ich Kampf mit Linux-Boxen im College zurück.
Here’s an essential automatic script and a cron job you will need in order to keep your backup automatic . Hier ist ein wesentlicher automatische Skript und einen Cron-Job werden Sie brauchen, um zu halten Ihr Backup automatisch.
Yes, if you get a dedicated server, don’t get their stupid extra $15/month for backing up your database. (All they do is make scripts like this one and charge you for it) Ja, wenn Sie einen dedizierten Server, nicht bekommen, ihre dummen extra $ 15/month für das Sichern Ihrer Datenbank. (Alles, was sie tun, ist die Erstellung von Skripten wie folgt ein und laden Sie zu it)
You can follow this example and go spend that money on junk food. Sie können diesem Beispiel folgen und gehen Sie verbringen das Geld für Junk Food.
So all you have to do is FTP your backup files. Also alles, was Sie zu tun haben, ist Ihr FTP-Backup-Dateien.
This is way better than going into your phpMyAdmin and downloading from the web interface since the file is already ready for you to download. Dieser Weg ist besser als sich in Ihren phpMyAdmin und das Herunterladen aus dem Web-Interface, da die Datei bereits fertig für Sie zum Download bereit.
Here’s how you do it: Hier erfahren Sie, wie Sie es tun:
1) Make a new file called backup.sh in your home directory. 1) Machen Sie eine neue Datei mit dem Namen "backup.sh in Ihrem Home-Verzeichnis. 2) Use the following syntax: 2) Verwenden Sie die folgende Syntax:
mysqldump -u[USERNAME] -p[PASSWORD] –opt [DATABASE NAME] > /root/backup/DATABASE1.sql mysqldump-u [USERNAME]-p [passwort]-Opt [Datenbankname]> / root/backup/DATABASE1.sql Here’s an example backup.sh file if you had 2 databases: Hier ist ein Beispiel backup.sh Datei, wenn Sie hatte 2 Datenbanken:
mysqldump -uUser1 -pPassword1 --opt Database1 > /root/backup/Database1.sql mysqldump -uUser2 -pPassword2 --opt Database2 > /root/backup/Database2.sql tar cvf /root/backup/sqlbackup.tar /root/backup/* mysqldump-uUser1-pPassword1 - opt Database1> / root/backup/Database1.sql mysqldump-uUser2-pPassword2 - opt Database2> / tar root/backup/Database2.sql CVF / root / Backup / sqlbackup.tar / root / backup / * You can test your script by typing this: Testen Sie Ihr Skript, indem Sie hierzu folgendermaßen vor:
sh backup.sh SH backup.sh (The mysqldump will overwrite the older file if you run this more than once) (Die mysqldump überschreibt die ältere Datei, wenn Sie diese mehr als einmal)
3) If everything is working good, now you can put that script to be run once a day in your cron job. 3) Wenn alles funktioniert gut, jetzt können Sie das Skript zu starten, einmal einen Tag in Ihrem cron-Job.
For Fedora Core, you can edit this file /etc/cron.d/sa-update Für Fedora Core, können Sie diese Datei / etc / cron.d / sa-Update
Add the following line: Fügen Sie die folgende Zeile:
10 3 * * * root sh /root/backup/backup.sh 10 3 * * * root sh / root / backup / backup.sh This will execute the script once a day at 3:10AM. Dies führt das Skript einmal pro Tag auf 3:10 Uhr.
Now simply download one tar ball file whenever you feel like backing up your database. Jetzt laden Sie einfach ein tar-ball-Datei, wenn Sie der Meinung sind, wie das Sichern Ihrer Datenbank.
You can probably change this a little bit and use it for many other things like backing up all your files too. Sie können dies ändern wahrscheinlich ein bisschen und verwenden Sie es für viele andere Dinge wie die Sicherung alle Ihre Dateien zu. (which I do) (which I do)
If you have multiple servers like me, you can also automate your scripts to download backup databases to each server. Wenn Sie mehrere Server wie ich, kann man auch automatisieren Ihre Skripte zum Download Backup-Datenbanken auf jedem Server. That keeps things real redundant in case of server failure. Das hält die Dinge real redundante im Falle von Server-Ausfall.






















