I would like to know how to do backup and restoration in an osTicket system.  I have checked the previous posts in this forum and know that the MySQL DB should be backed up and then restored using the following command.

Backup:       mysqldump -h -u -p >

Restoration: mysql -h -u -p <

So I know what should be done for the DB part. How about the backup for the file system? Any other things we need to back up?

 

The file system is as simple as just copying the files via FTP back to your local computer or storage device.I have a little perl script that I run via CRON that does this as well.  Then all you have is a single file to grab after.  Would be nice to have the software do this via CRON for you, then allow you the ability to import the DB back through the software...#!/usr/bin/perl

# System Backup

#------ Variables ------

$backupdir = "/usr/local/DirectoryOfBackUpLocation"; # "." for current

$other_dirs = "/usr/local/DirectoryToBeBackedUp1 /usr/local/DirectoryToBeBackedUp2";

#-----------------------

print "Backup Initiated...\n";

@[deleted] = localtime(time);

$newfilename = sprintf("%02d",$timenow+1) .

sprintf("%02d",$timenow) . ($timenow + 1900);

print "Using Filename: $newfilename.sql \n";

print "Starting database backup... \n";

system "mysqldump -qce -r $newfilename.sql -u root DataBaseName";

print "Starting Compression... \n";

system "tar czf $backupdir/$newfilename.tar.gz $other_dirs $newfilename.sql";

unlink "$newfilename.sql" || print "Error: Cannot delete file specified: $newfilename - $_ \n";

print "Done. \n"

Do you back up your webserver?If so then you can use that back up to restore the files.

Currently, we are using window environment, any suggestion ? Can you specify which file folders that we need to back up?

Personally I back up everything.At minimum to recover on another server in case of disaster you would want your osticket dir (and subfolders).And a dump of your database.

"The file system is as simple as just copying the files via FTP back to your local computer or storage device.

I have a little perl script that I run via CRON that does this as well.  Then all you have is a single file to grab after.  Would be nice to have the software do this via CRON for you, then allow you the ability to import the DB back through the software...

#!/usr/bin/perl # System Backup #------ Variables ------ $backupdir = "/usr/local/DirectoryOfBackUpLocation"; # "." for current $other_dirs = "/usr/local/DirectoryToBeBackedUp1 /usr/local/DirectoryToBeBackedUp2"; #----------------------- print "Backup Initiated...\n"; @[deleted] = localtime(time); $newfilename = sprintf("%02d",$timenow+1) . sprintf("%02d",$timenow) . ($timenow + 1900); print "Using Filename: $newfilename.sql \n"; print "Starting database backup... \n"; system "mysqldump -qce -r $newfilename.sql -u root DataBaseName"; print "Starting Compression... \n"; system "tar czf $backupdir/$newfilename.tar.gz $other_dirs $newfilename.sql"; unlink "$newfilename.sql" || print "Error: Cannot delete file specified: $newfilename - $_ \n"; print "Done. \n"Thanks for sharing but is there any possibility you could add some comments to let us know what the script is actually doing?

My Perl skills are a little rusty, but I think that this would be accurate:01. #!/usr/bin/perl02. # System Backup03. #------ Variables ------04. $backupdir = "/usr/local/DirectoryOfBackUpLocation"; # "." for current05. $other_dirs = "/usr/local/DirectoryToBeBackedUp1 /usr/local/DirectoryToBeBackedUp2";06. #-----------------------07. print "Backup Initiated...\n";08. @[deleted] = localtime(time);09. $newfilename = sprintf("%02d",$timenow+1) .10. sprintf("%02d",$timenow) . ($timenow + 1900);11. print "Using Filename: $newfilename.sql \n";12. print "Starting database backup... \n";13. system "mysqldump -qce -r $newfilename.sql -u root DataBaseName";14. print "Starting Compression... \n";15. system "tar czf $backupdir/$newfilename.tar.gz $other_dirs $newfilename.sql";16. unlink "$newfilename.sql" || print "Error: Cannot delete file specified: $newfilename - $_ \n";17. print "Done. \n"01. path to perl on your local system02. comment - does nothing.03. start of variables configuration area04 - 05. You need to set these variables according to your setup.06. end of variables configuration area07. prints contents between "'s to screen.08. sets variable to local time.09. set variable newFilename to unique name based on time.10. print to file.11. print contents between "'s to screen.12. print contents between "'s to screen.13. perform the following SQL query to create a backup.14. print contents between "'s to screen.15. perform the system command to tar (compress) the backup it just made.16. delete the .sql file since a copy of it is in the tar just created.17. print contents between "'s to screen.

Perfect thanks ntozier, now I just need to figure out how to GnuPG the file and then mail it off. Good script

This should point you in the right drection on how to modify that script to send email with the .tar as an attachment.http://www.perlmonks.org/?node_id=19430

Write a Reply...