Warning: opendir(/var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/sh/3.0.83.2/scripts/): failed to open dir: No such file or directory in /var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 26

Warning: Invalid argument supplied for foreach() in /var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 170
Skip to content

Shellscript - backup.sh


 
Möchte man vor einem neuen Backup ( z.b. ein MySQL-Dump ) prüfen ob die Datei vom Vortag noch existiert, kann man dies ganz einfach mit "Date" lösen.
 
Hier ein kleines Beispiel:
 
#
#Testen ob Datei vom Vortag existiert, falls ja -> löschen
#
if [ -e /backup/sql-`date -d ‘-1 day’ +%y%m%d`.tgz ]; then
        rm /backup/sql-`date -d ‘-1 day’ +%y%m%d`.tgz
fi

#
#Testen ob Datei sql.dump existiert, falls ja -> löschen
#
if [ -e /var/www/sql.dump ]; then
        rm /var/www/sql.dump
fi

#
#MySQLDump erstellen
#
/usr/bin/mysqldump -uBENUTZER -pPASSWORT  —single-transaction > /backup/sql.dump

#
#Dump-File packen und löschen
#
tar cvfz /backup/sql-`date ‘+%d%m%Y’`.tgz /backup/sql.dump && rm /backup/sql.dump
 

 
Download: backup.sh

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment


To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA 1CAPTCHA 2CAPTCHA 3CAPTCHA 4CAPTCHA 5


Textile-formatting allowed
You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Form options
Imprint | Contact | Privacy Statement

Warning: opendir(/var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/sh/3.0.83.2/scripts/): failed to open dir: No such file or directory in /var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 26

Warning: Invalid argument supplied for foreach() in /var/www/html/web1/serendipity/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 170