ISPConfig allow to manually backup sites to a FTP server. But is there a way to automate/schedule the backups and have them sent to a FTP server automatically ? Thanks. Henri
i have been looking for this for a while now as well. i like the way the ispconfig web interface backs up everything into a zip file, and you can unzip everything and use what you need. good for migration, and moving servers. very interested in thsi as well
Yes I love the zip thing too! There must be an easy way to automate the sending to a FTP server but I'm not enough expert in Linux to know about it.
Take a look at this tutorial: http://www.howtoforge.com/ftp-backups-with-duplicity-ftplicity-debian-etch
I'm not sure that it can work as I need to be sure that ISPConfig has finished to write the backup files before trying to send them to the FTP server. Wouldn't it be better to include some code after the PHP script of ISPConfig that creates sites backups? Do you know the location of this script and where I could append some code? I don't want to break the script and the comments are in German Thanks! Henri
hmm, gonna have to figure out how to add this as a cron job to run backup to an ftp server. thanks falko
This script is not made to run backups on a FTP server. It might be easoier if you write a custom shell script that simply makes a tar.gz file of the /var/www directory (or the place were your webs are stored) and then copy the tar.gz file to the ftp server.
My code to automate sending backups to FTP Server This the first version of the code I wrote to send backups to an FTP Server. It's really simple! You just have to add the codes between // HENRI and //~HENRI to the right places (near line 133) of the /root/ispconfig/scripts/shell/backup.php script. Beware that this script will send a new backup everyday and thus fill the FTP Server (it's a first version)! Henri PHP: // [...] // Delete temp file exec("rm -rf $tmp_dir"); // HENRI Send file to FTP server send_backup($web_id, $backup_dir, $backup_file_name); //~HENRI}// All web site$webs = $mod->db->queryAllRecords("SELECT * FROM isp_isp_web");if(!empty($webs)){ foreach($webs as $web){ do_backup($web['doc_id']); }}// HENRIfunction send_backup($web_id, $backup_dir, $backup_file_name) { // Replace by your own parameters $ftp_server = 'XXXXXXXX'; $ftp_user_name = 'XXXXXXXX'; $ftp_user_pass = 'XXXXXXXXX'; // Connect and login to FTP server $conn_id = @ftp_connect($ftp_server); $login_result = @ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if (!$conn_id || !$login_result) { echo "FTP connection failed for $ftp_user_name!\n"; return false; } else { echo "$ftp_user_name connected\n"; } // Create web_dir if necessary $web_dir = '/web'.$web_id; if (@ftp_mkdir($conn_id, $web_dir)) { echo "Created $web_dir\n"; } $destination_file = $web_dir.'/'.$backup_file_name; $source_file = $backup_dir.'/'.$backup_file_name; // Upload backup $upload = @ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // Display result if (!$upload) { echo "Failed sending $destination_file\n"; } else { echo "Successed sending $destination_file\n"; } // Close FTP connection @ftp_close($conn_id); return $upload;}//~HENRI
Hi, I suggest my Backup system for ISPConfig! http://www.howtoforge.com/forums/showthread.php?t=15337 Regards, mturillo
I use the filesystem backup function in Webmin. Very easy. You can shedule backups. Use SSH or FTP server. And you get an email on succes.
My code to automate sending backups to FTP Server (version 2) This version removes old backup from FTP server after a given number of days. Add the codes between // HENRI and //~HENRI to the right places in the /root/ispconfig/scripts/shell/backup.php script. PHP: set_time_limit(0); include("/root/ispconfig/scripts/lib/config.inc.php"); include("/root/ispconfig/scripts/lib/server.inc.php"); if($go_info["server"]["do_automated_backups"] != 1) die(); // Erstelle Namen für Backup Datei $backup_file_name = "backup_".date("Y_m_d",time()).".zip"; // HENRI // Replace with your own parameters define('FTP_SERVER', 'XXXXXXX'); define('FTP_USER_NAME', 'XXXXXXXXX'); define('FTP_USER_PASS', 'XXXXXXXXX'); define('FTP_DAYS', 20); // the script will keep FTP backups this number of days. Min value is 1. // set old_backup_file_name $old_time = mktime(0, 0, 0, date('m'), date('d') - FTP_DAYS, date('Y')); $old_backup_file_name = 'backup_'.date('Y_m_d', $old_time).'.zip'; //~HENRI // [...] // Delete temp file exec("rm -rf $tmp_dir"); // HENRI Send file to FTP server send_backup($web_id, $backup_dir); //~HENRI } // All web site $webs = $mod->db->queryAllRecords("SELECT * FROM isp_isp_web"); if(!empty($webs)){ foreach($webs as $web){ do_backup($web['doc_id']); } } // HENRI function send_backup($web_id, $backup_dir) { global $backup_file_name, $old_backup_file_name; // Connect and login to FTP server $conn_id = @ftp_connect(FTP_SERVER); $login_result = @ftp_login($conn_id, FTP_USER_NAME, FTP_USER_PASS); if (!$conn_id || !$login_result) { echo "FTP connection failed for ".FTP_USER_NAME."!\n"; return false; } else { echo FTP_USER_NAME." connected\n"; } // Create web_dir if necessary $web_dir = '/web'.$web_id; if (@ftp_mkdir($conn_id, $web_dir)) { echo "Created $web_dir\n"; } // Upload backup $destination_file = $web_dir.'/'.$backup_file_name; $source_file = $backup_dir.'/'.$backup_file_name; $uploaded = @ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // Display result if (!$uploaded) { echo "Failed sending $destination_file\n"; } else { echo "Successed sending $destination_file\n"; // Remove old backup $destination_file = $web_dir.'/'.$old_backup_file_name; if (@ftp_delete($conn_id, $destination_file)) { echo "Removed old backup: $destination_file\n"; } } // Close FTP connection @ftp_close($conn_id); return $uploaded; } //~HENRI Henri http://www.absyx.fr
thanks once again, this one is easier to follow. what is the best way to test and make sure this works? i tried running the php manually, and it doesnt do anything
Before you run the script, you must enable automated backup in ISPConfig's config file. In /home/admispconfig/ispconfig/lib/config.inc.php, find the line: PHP: $go_info["server"]["do_automated_backups"] = 0; // 0 = no, 1 = yes; PLEASE NOTE: automated backups might fill up your HDD fast! and set it to 1: PHP: $go_info["server"]["do_automated_backups"] = 1; // 0 = no, 1 = yes; PLEASE NOTE: automated backups might fill up your HDD fast! Save and restart ISPConfig server (not sure it's needed though): Code: /etc/init.d/ispconfig_server restart Then try to run the script manually: Code: /root/ispconfig/php/php /root/ispconfig/scripts/shell/backup.php Backup should start and you should see logs about backup files being sent to the FTP Server. Once it's done, connect to the FTP Server and check if the files are where they're expected to be Henri http://www.absyx.fr
got it, thanks. this script looks like what i wanted too. under ftp server, the correct syntax is Code: define('FTP_SERVER', '192.168.1.105/array1/web/'); correct?