Current time: 11-23-2024, 09:29 AM Hello There, Guest! (LoginRegister)


Post Reply 
[HowTo] How can I keep my backups for x days?
Author Message
miklosandras Offline
Junior Member
*

Posts: 27
Joined: Dec 2008
Reputation: 0
Post: #1
[HowTo] How can I keep my backups for x days?
Version 1.4 updated: 2010-01-25 compatible with ISPCP 1.03

First, we should make sql table for define, how long do you want to keep backups / domain.

Code:
CREATE TABLE IF NOT EXISTS `domain_backup` (
  `id` int(5) NOT NULL auto_increment,
  `domain_name` varchar(200) character set utf8 collate utf8_unicode_ci NOT NULL,
  `site_backup_days` smallint(2) NOT NULL,
  `db_backup_days` smallint(2) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


Next, please make this file:

/var/www/ispcp/engine/backup/archive_backups

check in the Attachment! or this txt:

http://yoursitehosting.net/archive_backups.txt

Make exec:

Code:
chmod +x /var/www/ispcp/engine/backup/archive_backups

Go and add this new line to crontab (/etc/cron.d/ispcp):

Code:
0 4 * * * root /var/www/ispcp/engine/backup/archive_backups > /dev/null

Please do a backup first about these files:

/var/www/ispcp/gui/reseller/domain_edit.php
/var/www/ispcp/gui/themes/omega_original/reseller/domain_edit.tpl

Code:
cp -p /var/www/ispcp/gui/themes/omega_original/reseller/domain_edit.tpl /var/www/ispcp/gui/themes/omega_original/reseller/domain_edit.tpl_backup
cp -p /var/www/ispcp/gui/reseller/domain_edit.php /var/www/ispcp/gui/reseller/domain_edit.php_backup

And if you never edited that files, then please replace them with the attachment files or these txts:

http://yoursitehosting.net/domain_edit_php.txt
http://yoursitehosting.net/domain_edit.tpl.txt

I created an instruction for manually edit these files if you don't want to repleace them:

http://yoursitehosting.net/domain_edit.p...y_line.txt
http://yoursitehosting.net/domain_edit.t...y_line.txt

And if you want custom days of keep backups per domain, then just update it at reseller level via edit domain, also you can set if you want to keep your site and/or your database backups:

[Image: ispcp_04.gif]

If you want to turn off the this new directory (/var/www/virtual/$domain_name/archive_backups) from quota, then please edit this file:

/var/www/ispcp/engine/quota/ispcp-dsk-quota (line 118):

Code:
my $s = `$cmd_du --exclude="backups/$domain_name-*.lzma" --exclude="backups/$domain_name-*.bz2" --exclude="backups/$domain_name-*.gz" --exclude="backups/*.sql.lzma" --exclude="backups/*.sql.bz2" --exclude="backups/*.sql.gz" --exclude="logs/*.log" -s -B1 $main::cfg{APACHE_WWW_DIR}/$domain_name`;

change to:

Code:
my $s = `$cmd_du --exclude="archive_backups" --exclude="backups/$domain_name-*.lzma" --exclude="backups/$domain_name-*.bz2" --exclude="backups/$domain_name-*.gz" --exclude="backups/*.sql.lzma" --exclude="backups/*.sql.bz2" --exclude="backups/*.sql.gz" --exclude="logs/*.log" -s -B1 $main::cfg{APACHE_WWW_DIR}/$domain_name`;

And we should edit the backup script too (/var/www/ispcp/engine/backup/ispcp-backup-all):

find this line: 269
Code:
$backup_cmd = "$cmd_tar --create --directory=$dmn_dir --$zip --file=$dmn_dir/$backup_filename --exclude=logs --exclude=phptmp --exclude=backups --exclude=$backup_filename --exclude=$backup_filename.log . 2> $dmn_dir/$backup_filename.log";

and change to:
Code:
$backup_cmd = "$cmd_tar --create --directory=$dmn_dir --$zip --file=$dmn_dir/$backup_filename --exclude=logs --exclude=phptmp --exclude=backups --exclude=archive_backups --exclude=$backup_filename --exclude=$backup_filename.log . 2> $dmn_dir/$backup_filename.log";

If you have any question, just pm me Smile

Script will create the directories (if not exist) and will create an entry to database too.

ps:at attachments, domain_edit.tpl.txt needed to rename to domain_edit.tpl
and also be carefully, if you will use online (txt) versions.

sitebackups renamed to archive_backups due to the script not only contain the site backups.

Thanks all to Kami and all other members, who help me.


Attached File(s)
.txt  domain_edit.tpl.txt (Size: 13.68 KB / Downloads: 18)
.txt  domain_edit.php.txt (Size: 31.45 KB / Downloads: 16)
.txt  archive_backups.txt (Size: 3.7 KB / Downloads: 14)
(This post was last modified: 01-25-2010 08:52 PM by miklosandras.)
03-19-2009 05:23 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
[HowTo] How can I keep my backups for x days? - miklosandras - 03-19-2009 05:23 PM

Forum Jump:


User(s) browsing this thread: 3 Guest(s)