Cpbackup Script - Append Date to Filename

steve-o

Registered
Jul 6, 2010
2
0
51
I am utilizing the built in backup feature in the Web Host Manager to backup and FTP my user accounts. This is working great however, the files are named simply by user account and thus I have no retention as the files get overwritten every time my backup runs.

I would like to modify this backup script to append the current date. Does anyone have any experience doing this?

I am a designer by trade :eek: and I don't know Perl so if anyone some code snipits I could just copy and paste I would be very appreciative!!!

cPanel 11.24.5-S38506 - WHM 11.24.2 - X 3.9
CENTOS 5.2 i686 standard
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,544
14
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
I am utilizing the built in backup feature in the Web Host Manager to backup and FTP my user accounts. This is working great however, the files are named simply by user account and thus I have no retention as the files get overwritten every time my backup runs.

I would like to modify this backup script to append the current date. Does anyone have any experience doing this?

I am a designer by trade :eek: and I don't know Perl so if anyone some code snipits I could just copy and paste I would be very appreciative!!!

cPanel 11.24.5-S38506 - WHM 11.24.2 - X 3.9
CENTOS 5.2 i686 standard
Please note that the specified cPanel version is out-of-date; to ensure you receive the latest bug-fixes, feature enhancements, and new features, I recommend updating the system to the latest STABLE build, that of version 11.25.0-STABLE_46156 (released Wed Jun 2 16:17:01 2010).

Knowing Perl is not required, thought it certainly may help; if you can devise a shell script (or have someone assist with developing a custom script) to rename the desired files (or directories) then it is possible to set that custom script to be executed after the automated cPanel backups are generated. This can be accomplished by using built-in support for "pre" and "post" script hooks such as the following, not setup by default, at "/scripts/postcpbackup" (where this file is your custom script that would be automatically executed).

The following areas of our documentation detail how to use the aforementioned built-in hooks:

One possibility, that I believe should be relatively simple or straight-forward, is to have a script that simply issues a command that renames the desired backup directory (e.g., daily) to be appended with the date and time. If the directory to be renamed is on a remote server (i.e., the same server being used for remote FTP storage), the command entered into the postcpbackup script may utilize SSH and authentication via SSH keys to access the remote server to rename the desired directory, or, if more complex rotation is needed, the command sent via SSH could simply trigger the execution of a script that remains stored on the remote system.

If needing more in-depth assistance with developing a custom script and or setup of the desired customizations I recommend posting a request in the following sub-section of the advertising forums area: Server Management and Server Repair - cPanel Forums
 
Last edited:

Lyttek

Well-Known Member
Jan 2, 2004
775
5
168
There are a couple of threads you should look into... (use search)

On my servers, I typically have a simple rotation script that uses a directory for each day of the week.
 

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
There's a simple but very usable backup rotation script described here, not that I'm biased:

http://forums.cpanel.net/478685-post10.html

I think it does what you want, and you don't need to learn perl! We've been using it for 2-3 years now, and several others appear to have picked it up and started using it.

It works through the "postcpbackup" hook script which makes it very neat, and is configurable to retain N versions of daily/weekly/monthly history. The script contains comments telling you how to use it.