Current time: 12-26-2024, 10:51 AM Hello There, Guest! (LoginRegister)


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

Posts: 570
Joined: Feb 2009
Reputation: 4
Post: #11
RE: How can I keep my backups for x days?
is it possible to add a feature in this addon which adds a folder or filelist what has to be included in the Backup?
07-29-2009 10:25 PM
Find all posts by this user Quote this message in a reply
Kami Offline


Posts: 4
Joined: Jul 2009
Reputation: 0
Post: #12
RE: How can I keep my backups for x days?
Here is a working and improved version (tested on Debian Lenny).

.php  sitebackups.php (Size: 3.08 KB / Downloads: 18)

Obviously previous version threw an error and didn't delete the file on some systems, because file name is the 8th and not 9th parameter in the ls -lrt output.

I've also added an --color=never switch, because colors could cause problems with the file names on some systems.

Oh, and if you don't want your crontab log file to be filled with the script output, use this cron entry:

Quote:0 4 * * * root /var/www/ispcp/engine/backup/sitebackups.php > /dev/null

Regards
(This post was last modified: 08-02-2009 07:03 PM by Kami.)
08-01-2009 04:13 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Kami Offline


Posts: 4
Joined: Jul 2009
Reputation: 0
Post: #13
RE: How can I keep my backups for x days?
Here is another version which deletes old backups based on the date in the file name instead of using the file creation date (if something goes wrong and ISPCP doesn't creates new backups old backups will still be deleted).


.php  sitebackups.php (Size: 3.16 KB / Downloads: 10)
08-04-2009 12:24 AM
Visit this user's website Find all posts by this user Quote this message in a reply
MasterTH Offline
Member
***

Posts: 570
Joined: Feb 2009
Reputation: 4
Post: #14
RE: How can I keep my backups for x days?
you could code an counter which counts the files in the backup-folder with tar.gz in the end. If the amount of files is bigger then the number of backups given from the user ispcp can delete the oldest files.
08-04-2009 02:39 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: #15
RE: How can I keep my backups for x days?
I was in vacation, now I am back, thanks for all answers and responses about my topic. I made some change with the script, thanks to Kami!

First post updated with new version!

(07-07-2009 08:01 AM)FISA4 Wrote:  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

Now, at reseller level, you can set different values for site and database backups too.

"set the value(s) if you create a new user" will be implemented soon.

(07-29-2009 03:48 PM)BeNe Wrote:  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

Sorry, I can not create Patch for the current trunk, anyone could help me?

Best Regards,
Andras
(This post was last modified: 08-04-2009 05:32 PM by miklosandras.)
08-04-2009 05:31 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: #16
RE: How can I keep my backups for x days?
i can help with the patch ...

For me just one important feature is missing :
User should be able to select which backup to use to restore their data.
(and of course in combination with the splitting of sql / file data)
08-04-2009 07:34 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kami Offline


Posts: 4
Joined: Jul 2009
Reputation: 0
Post: #17
RE: How can I keep my backups for x days?
(08-04-2009 02:39 PM)MasterTH Wrote:  you could code an counter which counts the files in the backup-folder with tar.gz in the end. If the amount of files is bigger then the number of backups given from the user ispcp can delete the oldest files.

Yes, that would work as well, but that solution would require 1 extra step.

First I would need to count all the files matching the pattern and then I would still need to delete the files based on the date in the file name (assuming that the ISPCP backups are "compromised" and that the file creation date is incorrect).

@miklosandras: Great Smile
08-04-2009 07:50 PM
Visit this user's website Find all posts by this user Quote this message in a reply
miklosandras Offline
Junior Member
*

Posts: 27
Joined: Dec 2008
Reputation: 0
Post: #18
RE: How can I keep my backups for x days?
(08-04-2009 07:34 PM)ephigenie Wrote:  i can help with the patch ...

For me just one important feature is missing :
User should be able to select which backup to use to restore their data.
(and of course in combination with the splitting of sql / file data)

Thanks for your help.

I know the solution for restore what was in

/var/www/ispcp/engine/ispcp-dmn-mngr

but, I am not good at perl...
08-04-2009 08:14 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kami Offline


Posts: 4
Joined: Jul 2009
Reputation: 0
Post: #19
RE: How can I keep my backups for x days?
(08-04-2009 08:14 PM)miklosandras Wrote:  
(08-04-2009 07:34 PM)ephigenie Wrote:  i can help with the patch ...

For me just one important feature is missing :
User should be able to select which backup to use to restore their data.
(and of course in combination with the splitting of sql / file data)

Thanks for your help.

I know the solution for restore what was in

/var/www/ispcp/engine/ispcp-dmn-mngr

but, I am not good at perl...

There is a one small bug in your script (same as in my first version).

Code:
exec("ls -lrt --color=never /var/www/virtual/".$domain_name."/archive_backups/ | grep '$delete_day1' | awk '{print $8}' | xargs rm -f");

If you don't change the working directory to /var/www/virtual/".$domain_name."/archive_backups/ you need to supply the full path to the rm command, else script will try to delete these files in the current working directory instead of /var/www/virtual/".$domain_name."/archive_backups/.
08-04-2009 08:40 PM
Visit this user's website Find all posts by this user Quote this message in a reply
miklosandras Offline
Junior Member
*

Posts: 27
Joined: Dec 2008
Reputation: 0
Post: #20
RE: How can I keep my backups for x days?
(08-04-2009 08:40 PM)Kami Wrote:  
(08-04-2009 08:14 PM)miklosandras Wrote:  
(08-04-2009 07:34 PM)ephigenie Wrote:  i can help with the patch ...

For me just one important feature is missing :
User should be able to select which backup to use to restore their data.
(and of course in combination with the splitting of sql / file data)

Thanks for your help.

I know the solution for restore what was in

/var/www/ispcp/engine/ispcp-dmn-mngr

but, I am not good at perl...

There is a one small bug in your script (same as in my first version).

Code:
exec("ls -lrt --color=never /var/www/virtual/".$domain_name."/archive_backups/ | grep '$delete_day1' | awk '{print $8}' | xargs rm -f");

If you don't change the working directory to /var/www/virtual/".$domain_name."/archive_backups/ you need to supply the full path to the rm command, else script will try to delete these files in the current working directory instead of /var/www/virtual/".$domain_name."/archive_backups/.

Thanks, script updated, and tested, works fine Smile
08-04-2009 09:21 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: 5 Guest(s)