Current time: 11-23-2024, 04:15 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
FISA4 Offline
Member
***

Posts: 668
Joined: Feb 2008
Reputation: 15
Post: #2
RE: How can I keep my backups for x days?
What to do if i want to keep only databases for some days?

Greets

FISA4
(This post was last modified: 03-20-2009 10:36 AM by FISA4.)
03-20-2009 10:35 AM
Find all posts by this user Quote this message in a reply
miklosandras Offline
Junior Member
*

Posts: 27
Joined: Dec 2008
Reputation: 0
Post: #3
RE: How can I keep my backups for x days?
(03-20-2009 10:35 AM)FISA4 Wrote:  What to do if i want to keep only databases for some days?

Greets

FISA4

I updated the script Smile

added addon to keep only database backups or keep only sitebackups or keep both backups:

PHP Code:
// $keep_db = "yes"; it is mean you can enable to keep database backups ( to disable: $keep_db = "no"; )
// $keep_site = "yes"; it is mean you can enable to keep site backups( to disable: $keep_site = "no"; ) 

First post will be update soon. Smile

Attachment added to the first post!
(This post was last modified: 03-20-2009 06:46 PM by miklosandras.)
03-20-2009 06:43 PM
Visit this user's website Find all posts by this user Quote this message in a reply
FISA4 Offline
Member
***

Posts: 668
Joined: Feb 2008
Reputation: 15
Post: #4
RE: How can I keep my backups for x days?
great,

now we have to create a script which autoupdate the database

something like that:
PHP Code:
$sql "SELECT `domain` FROM `domain`";
$query=mysql_query($sql);
while(
$rs mysql_fetch_array($query))
{
$sql2 "INSERT INTO `domain_backup` (`id`, `domain_name`, `backup_days`) VALUES ("", '$rs['domain']', 8);";
$query2 mysql_query($sql2);


change "domain_add.php" and "domain_add.tpl" (i don´t know the real name of the files ) in reseller to automatic create the entry.

and

change

"domain_edit.php" and "domain_edit.tpl" to change the value of `backup_days`

and make a patch-file for the changes.

Then we have a great enhancement for ispCP

Greets

FISA4
03-21-2009 02:50 AM
Find all posts by this user Quote this message in a reply
FISA4 Offline
Member
***

Posts: 668
Joined: Feb 2008
Reputation: 15
Post: #5
RE: How can I keep my backups for x days?
i followed the HowTo and i got an error:

alpha:~# /var/www/ispcp/engine/backup/./sitebackups.php
rm: fehlender Operand
ârm --helpâ gibt weitere Informationen.
X-Powered-By: PHP/5.2.6-1+lenny2
Content-type: text/html

the site backup and the sql backup are OK
03-23-2009 07:59 PM
Find all posts by this user Quote this message in a reply
miklosandras Offline
Junior Member
*

Posts: 27
Joined: Dec 2008
Reputation: 0
Post: #6
RE: How can I keep my backups for x days?
(03-23-2009 07:59 PM)FISA4 Wrote:  i followed the HowTo and i got an error:

alpha:~# /var/www/ispcp/engine/backup/./sitebackups.php
rm: fehlender Operand
ârm --helpâ gibt weitere Informationen.
X-Powered-By: PHP/5.2.6-1+lenny2
Content-type: text/html

the site backup and the sql backup are OK

Yes, may it show some error, but it is working fine, and now released 1.0

Check the first post! Smile
07-07-2009 04:52 AM
Visit this user's website Find all posts by this user Quote this message in a reply
FISA4 Offline
Member
***

Posts: 668
Joined: Feb 2008
Reputation: 15
Post: #7
RE: How can I keep my backups for x days?
(07-07-2009 04:52 AM)miklosandras Wrote:  
(03-23-2009 07:59 PM)FISA4 Wrote:  i followed the HowTo and i got an error:

alpha:~# /var/www/ispcp/engine/backup/./sitebackups.php
rm: fehlender Operand
ârm --helpâ gibt weitere Informationen.
X-Powered-By: PHP/5.2.6-1+lenny2
Content-type: text/html

the site backup and the sql backup are OK

Yes, may it show some error, but it is working fine, and now released 1.0

Check the first post! Smile

Great work,

it would be nice to have:

different values for site and database backups. Wink
set the value(s) if you create a new user.



in ispCP 1.0.1 we have the choice to switch off backups.
it would be nice, if you could build your add-on new with the latest nightly version because
the backup on/off is functionally since r1707 -> http://www.isp-control.net/ispcp/changeset/1707
and there are some changes in ispcp-backup-all, domain_edit.php and domain_edit.tpl


greets

FISA4
(This post was last modified: 07-07-2009 08:24 AM by FISA4.)
07-07-2009 08:01 AM
Find all posts by this user Quote this message in a reply
ephigenie Offline
Project Leader
*******
Administrators

Posts: 1,578
Joined: Oct 2006
Reputation: 15
Post: #8
RE: How can I keep my backups for x days?
Nice addon & and candidate for builtin Wink

One more thing : since there'is not only one Backup anymore,
it would be nice if the user can decide to which one he wants to fall back in case he needs to
jump over a day or 2 ...
07-29-2009 01:00 AM
Visit this user's website Find all posts by this user Quote this message in a reply
BeNe Offline
Moderator
*****
Moderators

Posts: 5,899
Joined: Jan 2007
Reputation: 68
Post: #9
RE: How can I keep my backups for x days?
Good Point! So the user should have the ability to select a Backup with a Radio-Button ?! Cool

If miklosandras can create a Patch for the current trunk, we can add this also in the SVN or ? Anyone against it ?

Greez BeNe
07-29-2009 03:48 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ephigenie Offline
Project Leader
*******
Administrators

Posts: 1,578
Joined: Oct 2006
Reputation: 15
Post: #10
RE: How can I keep my backups for x days?
I think so - from a first view it seems ok for me.

There might be still some issues regarding quota calculation (are ALL the Backups excluded)
I mean if a reseller might set "keep backups" to lets say 60 days and one of the pages of his customers is some kind of bigger online shop with maybe 2 gb - then this'll add up to 120 gb.
And maybe only 2 gb is counted ... so there should be a switch for admins to allow their resellers to have quota with and without backups .
07-29-2009 05:27 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


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