@echo off @rem ******************************************************************************************************************* @rem ** Author: Robert Lie (Mobilefish.com) @rem ** @rem ** backup_drupal_database_and_templates_with_winzip.bat @rem ** @rem ** Makes a backup of the drupal database and templates. @rem ** One backup file is created: _.zip @rem ** For example: 20060520_1252.zip @rem ** @rem ** Software requirement: @rem ** - Windos XP @rem ** - Winzip Pro @rem ** - WinZip Command Line Support Add-On @rem ** - MySQL 3.23.55 or higher @rem ** - Drupal 4.7.0. @rem ** @rem ** This backup file is also password protected by WinZip. @rem ** @rem ** This zip 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__.zip @rem ** For example: drupal_templates_20060520_1756.zip @rem ** This zip file contains the complete drupal main directory @rem ** @rem ** This script only works on Windows 2000 and XP because @rem ** option "usebackq" is only valid for these operating systems. @rem ** @rem ** This script is based on a Dutch or English date and time settings. @rem ** @rem ** Explanation: @rem ** 1)If you have a Dutch date setting, @rem ** type in a dos window: date [enter] @rem ** You will see something like: @rem ** Huidige datum: ma 15-05-2006 @rem ** ^ ^ ^ ^ @rem ** | | | | @rem ** | | | +----- year: token 4 @rem ** | | +-------- month: token 3 @rem ** | +------------ day: token 2 @rem ** +--------------- day of week: token 1 @rem ** @rem ** Note 1: The text "Huidige datum: " is NOT part of any token. @rem ** Note 2: In this script TWO delimeters are used "-" AND " " @rem ** If you leave out delimeter " " then the first token is @rem ** ma 15 @rem ** @rem ** 2)If you have a Dutch time setting, @rem ** type in a dos window: time [enter] @rem ** You will see something like: @rem ** Huidige tijd: 17:56:38,07 @rem ** ^ ^ ^ ^ @rem ** | | | | @rem ** | | | +------ hunderds of seconds: token 3 @rem ** | | +-------- seconds: token 3 @rem ** | +------------ minutes: token 2 @rem ** +--------------- hours: token 1 @rem ** @rem ** Note 1: The text "Huidige tijd: " is NOT part of any token. @rem ** Note 2: In this script ONE delimeter is used ":" @rem ** Note 3: Token 3 is "38 07". The comma is not displayed. @rem ** @rem ** 3)If you have a English date setting, @rem ** type in a dos window: date [enter] @rem ** You will see something like: @rem ** The current date is: Wed 05/17/2006 @rem ** ^ ^ ^ ^ @rem ** | | | | @rem ** | | | +----- year: token 4 @rem ** | | +--------- day: token 3 @rem ** | +------------ month: token 2 @rem ** +--------------- day of week: token 1 @rem ** @rem ** Note 1: The text "The current date is: " is NOT part of any token. @rem ** Note 2: In this script TWO delimeters are used "/" AND " " @rem ** If you leave out delimeter " " then the first token is @rem ** Wed 05 @rem ** @rem ** 4)If you have a English time setting, @rem ** type in a dos window: time [enter] @rem ** You will see something like: @rem ** The current time is: 12:00:16.04 @rem ** ^ ^ ^ ^ @rem ** | | | | @rem ** | | | +------ hunderds of seconds: token 3 @rem ** | | +-------- seconds: token 3 @rem ** | +------------ minutes: token 2 @rem ** +--------------- hours: token 1 @rem ** @rem ** Note 1: The text "The current time is: " is NOT part of any token. @rem ** Note 2: In this script ONE delimeter is used ":" @rem ** Note 3: Token 3 is "38 07". The comma is not displayed. @rem ** @rem ** 5) If you do not have a Dutch or English date and time setting @rem ** change the token and delimeters according to your situation. @rem ** @rem ** More information about Drupal see: @rem ** https://www.mobilefish.com/developer/drupal/drupal_quickguide_47.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_backupwinzip.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 WINZIP_DIR="C:\Tools\winzip" set WINZIP_PASSWORD="mywinzipsecret" set LANGUAGE=english @rem *** Start ********************************************************************************************************* if "%LANGUAGE%"=="english" goto english if "%LANGUAGE%"=="dutch" goto dutch @rem *** Dutch settings ************************************************************************************************ :dutch @rem Fill the day, month en year variables for /F "usebackq tokens=2 delims=- " %%i in ('%DATE%') do set day=%%i for /F "usebackq tokens=3 delims=- " %%i in ('%DATE%') do set month=%%i for /F "usebackq tokens=4 delims=- " %%i in ('%DATE%') do set year=%%i @rem Fill the hour and minute variables for /F "usebackq tokens=1 delims=:" %%i in ('%TIME%') do set hour=%%i for /F "usebackq tokens=2 delims=:" %%i in ('%TIME%') do set minute=%%i goto create @rem *** English settings ********************************************************************************************** :english @rem Fill the day, month en year variables for /F "usebackq tokens=3 delims=/ " %%i in ('%DATE%') do set day=%%i for /F "usebackq tokens=2 delims=/ " %%i in ('%DATE%') do set month=%%i for /F "usebackq tokens=4 delims=/ " %%i in ('%DATE%') do set year=%%i @rem Fill the hour and minute variables for /F "usebackq tokens=1 delims=:" %%i in ('%TIME%') do set hour=%%i for /F "usebackq tokens=2 delims=:" %%i in ('%TIME%') do set minute=%%i goto create @rem *** Step 1: Create date dependent directory *********************************************************************** :create set datetime="%year%%month%%day%_%hour%%minute%" set dir="%BACKUP_DIR%\%datetime%" 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 @rem @rem wzzip -P -r -k @rem wzzip = WinZip command line tool @rem -P = Store folder names. @rem -r = Include sub folders. @rem -k = Do not update the Zip files file date; retain the original date. @rem cd %WINZIP_DIR% wzzip -P -r -k %dir%\drupal_templates_%datetime%.zip %DRUPAL_DIR%\*.* @rem *** Step 4: Create one backup file containing files from step 2 and step 3 and password protect the file ********** @rem Do not change anything below unless you know what you are doing @rem wzzip -s -ycAES256 @rem wzzip = WinZip command line tool @rem -s = Specify a password. @rem -ycAES256 = Use the 256-bit AES encryption encryption method. @rem cd %WINZIP_DIR% wzzip -s%WINZIP_PASSWORD% -ycAES256 %BACKUP_DIR%\%datetime%.zip %dir%\*.* @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%