Simply download the batch file below on the machine hosting your Moodle server, modify it with your information (i.e. paths to the relevant directories, etc.), then run the batch file. The batch file is hosted on Rapidshare.com and can be downloaded from there.
For the batch file to work, I make the following assumptions:
- You are running your Moodle server in a Windows environment, and you have administrator access on the machine hosting your Moodle server.
- You are using MySQL Server as your database server.
- You have installed 7-Zip (http://www.7-zip.org/) on the machine hosting your Moodle server.
The full source code (with detailed comments) of the batch file is as follows:
@echo off
REM ======================== DEFINE SETTINGS AS REQUIRED ========================
REM Set timestamp in DDMMYYYY format
set TIMESTAMP=%date:~7,2%%date:~4,2%%date:~10,4%
REM Set the location of the 7-Zip executable
set ZIP="C:\Program Files\7-Zip\7z.exe"
REM Set the output folder where the zip file will be stored (temporarily)
set OUTPUT_FOLDER="C:\outputfolder"
REM Set location of the moodledata folder
set MOODLE_DATA="D:\moodledata"
REM Set name of zip file
set ARCHIVE=%OUTPUT_FOLDER%\moodle_backup_%TIMESTAMP%.zip
REM Set location of where your Moodle site resides
set MOODLE_CODE="C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\moodle"
REM Set location of the mysqldump executable
set DB_MYSQLDUMP="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe"
REM Set the database parameters: -u<username> -p<password> <database_name>
set DB_PARAMETERS=-uusername -ppassword moodledb
REM Set name of SQL dump file
set DB_DUMP_FILE="%OUTPUT_FOLDER%\moodledb_%TIMESTAMP%.sql"
REM Set the location of your FTP server (IP address is also fine)
set FTP_SERVER=myftp.network.com
REM Set FTP username - the user should have write access
set FTP_USER=ftpuser
REM Set FTP user's password
set FTP_PASSWORD=ftppassword
REM Set the FTP path to where you want to copy the archive file starting from the FTP root
set FTP_DESTINATION_DIRECTORY="/path/to/FTP/destination/"
REM ================= DO NOT MODIFY ANYTHING BELOW THIS LINE ==================
REM Backup Moodle data directory
%ZIP% a -tzip %ARCHIVE% %MOODLE_DATA%
REM Backup the Moodle code
%ZIP% a -tzip %ARCHIVE% %MOODLE_CODE%
REM Backup the Moodle database
%DB_MYSQLDUMP% %DB_PARAMETERS% > %DB_DUMP_FILE%
%ZIP% a -tzip %ARCHIVE% %DB_DUMP_FILE%
REM Upload via FTP
echo user %FTP_USER%> %OUTPUT_FOLDER%\ftpcmd.dat
echo %FTP_PASSWORD%>> %OUTPUT_FOLDER%\ftpcmd.dat
echo bin>> %OUTPUT_FOLDER%\ftpcmd.dat
echo cd %FTP_DESTINATION_DIRECTORY%>> %OUTPUT_FOLDER%\ftpcmd.dat
echo put %ARCHIVE%>> %OUTPUT_FOLDER%\ftpcmd.dat
echo quit>> %OUTPUT_FOLDER%\ftpcmd.dat
ftp -n -s:%OUTPUT_FOLDER%\ftpcmd.dat %FTP_SERVER%
REM Clean up
del %OUTPUT_FOLDER%\%DB_DUMP_FILE%
del %OUTPUT_FOLDER%\ftpcmd.dat
del %OUTPUT_FOLDER%\%ARCHIVE%
REM ======================== DEFINE SETTINGS AS REQUIRED ========================
REM Set timestamp in DDMMYYYY format
set TIMESTAMP=%date:~7,2%%date:~4,2%%date:~10,4%
REM Set the location of the 7-Zip executable
set ZIP="C:\Program Files\7-Zip\7z.exe"
REM Set the output folder where the zip file will be stored (temporarily)
set OUTPUT_FOLDER="C:\outputfolder"
REM Set location of the moodledata folder
set MOODLE_DATA="D:\moodledata"
REM Set name of zip file
set ARCHIVE=%OUTPUT_FOLDER%\moodle_backup_%TIMESTAMP%.zip
REM Set location of where your Moodle site resides
set MOODLE_CODE="C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\moodle"
REM Set location of the mysqldump executable
set DB_MYSQLDUMP="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe"
REM Set the database parameters: -u<username> -p<password> <database_name>
set DB_PARAMETERS=-uusername -ppassword moodledb
REM Set name of SQL dump file
set DB_DUMP_FILE="%OUTPUT_FOLDER%\moodledb_%TIMESTAMP%.sql"
REM Set the location of your FTP server (IP address is also fine)
set FTP_SERVER=myftp.network.com
REM Set FTP username - the user should have write access
set FTP_USER=ftpuser
REM Set FTP user's password
set FTP_PASSWORD=ftppassword
REM Set the FTP path to where you want to copy the archive file starting from the FTP root
set FTP_DESTINATION_DIRECTORY="/path/to/FTP/destination/"
REM ================= DO NOT MODIFY ANYTHING BELOW THIS LINE ==================
REM Backup Moodle data directory
%ZIP% a -tzip %ARCHIVE% %MOODLE_DATA%
REM Backup the Moodle code
%ZIP% a -tzip %ARCHIVE% %MOODLE_CODE%
REM Backup the Moodle database
%DB_MYSQLDUMP% %DB_PARAMETERS% > %DB_DUMP_FILE%
%ZIP% a -tzip %ARCHIVE% %DB_DUMP_FILE%
REM Upload via FTP
echo user %FTP_USER%> %OUTPUT_FOLDER%\ftpcmd.dat
echo %FTP_PASSWORD%>> %OUTPUT_FOLDER%\ftpcmd.dat
echo bin>> %OUTPUT_FOLDER%\ftpcmd.dat
echo cd %FTP_DESTINATION_DIRECTORY%>> %OUTPUT_FOLDER%\ftpcmd.dat
echo put %ARCHIVE%>> %OUTPUT_FOLDER%\ftpcmd.dat
echo quit>> %OUTPUT_FOLDER%\ftpcmd.dat
ftp -n -s:%OUTPUT_FOLDER%\ftpcmd.dat %FTP_SERVER%
REM Clean up
del %OUTPUT_FOLDER%\%DB_DUMP_FILE%
del %OUTPUT_FOLDER%\ftpcmd.dat
del %OUTPUT_FOLDER%\%ARCHIVE%
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteExploring this website is a highly engaging and rewarding experience. I want to express my gratitude for providing exceptional and unique content.
ReplyDeleteItalian schengen visa application from nigeria