@echo off @rem ******************************************************************************************************************* @rem ** Author: Robert Lie (Mobilefish.com) @rem ** @rem ** backup_drupal_database_and_templates_with_cygwin.bat @rem ** @rem ** Makes a backup of the drupal database and templates. @rem ** One backup file is created: _.tgz @rem ** For example: 20060520_1252.tgz @rem ** @rem ** Software requirement: @rem ** - Windos XP @rem ** - Cygwin (tar and date tools are used) @rem ** - MySQL 3.23.55 or higher @rem ** - Drupal 4.7.0. @rem ** @rem ** This tgz file contains two files: @rem ** 1. drupal__.sql @rem ** For example: drupal_20060520_1252.sql @rem ** This file contains the drupal database backup @rem ** @rem ** 2. drupal_templates__.tgz @rem ** For example: drupal_templates_20060520_1756.tgz @rem ** This tgz file contains the complete drupal main directory @rem ** @rem ** @rem ** More information about Drupal see: @rem ** https://www.mobilefish.com/developer/drupal/drupal_quickguide_47.html @rem ** @rem ** More information about Cygwin see: @rem ** https://www.mobilefish.com/developer/cygwin/cygwin.html @rem ** @rem ** More information about MySQL see: @rem ** https://www.mobilefish.com/developer/mysql/mysql.html @rem ** @rem ** More information about this script see: @rem ** https://www.mobilefish.com/developer/drupal/drupal_quickguide_backupcygwin.html @rem ** @rem ******************************************************************************************************************* @rem Change the following settings according to your situation set MYSQL_DIR=C:\Tools\mysql\bin set MYSQL_USER_ACCOUNT=root set MYSQL_USER_PASSWORD=mysecret set MYSQL_DATABASE=drupal set SCRIPT_DIR=C:\drupal_backup set BACKUP_DIR=%SCRIPT_DIR%\backup set DRUPAL_DIR=C:\mobilefish_drupal set CYGWIN_DIR=c:\tools\cygwin @rem *** Step 1: Create date dependent directory *********************************************************************** %CYGWIN_DIR%\bin\date +%%Y%%m%%d_%%H%%M% > date.txt for /f "delims=" %%a in ('type "date.txt" 2^>NUL') do set datetime=%%a set dir=%BACKUP_DIR%\%datetime% del date.txt if not exist %dir% mkdir %dir% @rem *** Step 2: Create backup database ******************************************************************************** @rem Do not change anything below unless you know what you are doing cd %MYSQL_DIR% mysqldump --allow-keywords --opt -u%MYSQL_USER_ACCOUNT% -p%MYSQL_USER_PASSWORD% %MYSQL_DATABASE% > %dir%\drupal_%datetime%.sql @rem *** Step 3: Create backup drupal templates ************************************************************************ @rem Do not change anything below unless you know what you are doing cd %dir% tar czf drupal_templates_%datetime%.tgz %DRUPAL_DIR% @rem *** Step 4: Create one backup file containing files from step 2 and step 3 **************************************** @rem Do not change anything below unless you know what you are doing cd %BACKUP_DIR% tar czf %datetime%.tgz %datetime% @rem *** Step 5: Delete the date dependent directory ******************************************************************* @rem ****************************************************** @rem * VERIFY IF %dir% IS SET CORRECTLY * @rem * ONLY THEN ENABLE THE STATEMENT BELOW * @rem * * @rem ****************************************************** @rem rmdir /S /Q %dir% @rem *** Step 6: Return to backup script directory ********************************************************************* cd %SCRIPT_DIR%