Is is possible to script a daily backup of a solution inside the repository?
Or possibly is some other way export a solution to a file?
CREATE EVENT NightlyBackup
SCHEDULE
START TIME '23:00' EVERY 24 HOURS
HANDLER
BEGIN
DECLARE cmd LONG VARCHAR;
DECLARE day_name CHAR(20);
SET day_name = DATENAME(WEEKDAY, CURRENT DATE);
SET cmd = 'BACKUP DATABASE DIRECTORY ' ||
'''d:\\backups\\' || day_name || ''' ' ||
'TRANSACTION LOG RENAME';
EXECUTE IMMEDIATE WITH ESCAPES OFF cmd;
END
elyod_72 wrote:I don't understand. I know I can do it manually in: file->Resopsitory ->Export to File.
My question is: Is there a way to set up a scheduled method that will export the solution to a file automatically?
// Ask for the destination directory
var confirm = plugins.dialogs.showWarningDialog('DB Backup','The Backup can take several minutes, proceed with the Backup?','Cancel','Ok')
if ( confirm == 'Cancel')
{
return;
}
plugins.dialogs.showInfoDialog('DB Backup','Select the directory where you want to save your Backup.','Ok')
var backup_dir = plugins.file.showDirectorySelectDialog();
// Usciamo se l'utente ha cancellato l'operazione
if (!backup_dir)
{
return;
}
// Create the new record
controller.newRecord(true)
database_file = globals.sintpro_backup_current_db_file
database_log_file = globals.sintpro_backup_current_log_file
db_file_size = globals.sintpro_backup_db_size
db_log_size = globals.sintpro_backup_log_size
// We reorder the list
controller.sort('backup_timestamp desc')
// We create a subdir in the destination dir
backup_dir = backup_dir + '/Backup_' + backupsid
backup_path = plugins.file.convertStringToJSFile(backup_dir)
// Execute the Stored Procedure called 'backup'
// We use an ALTER stament on the procedure so if it doesn't exists
// is created on the fly
var iArray = new Array(2);
var argArray = new Array(2);
// SP output parameter
iArray[0] = 1
argArray[0] = java.sql.Types.INTEGER
// SP input parameter
iArray[1] = 0
argArray[1] = backup_dir
// Let's start a progress bar to give the user some feedback
// Too bad the progress bar doesn't update... :(
forms.sintpro_backup_main.elements.progress_bar.visible = true
forms.sintpro_backup_main.elements.progress_bar.orientation = 0
forms.sintpro_backup_main.elements.progress_bar.stringPainted = true
forms.sintpro_backup_main.elements.progress_bar.string = "Performing Backup..."
forms.sintpro_backup_main.elements.progress_bar.value =0
forms.sintpro_backup_main.elements.progress_bar.minimum = 0
forms.sintpro_backup_main.elements.progress_bar.maximum = 100
forms.sintpro_backup_main.elements.progress_bar.indeterminate
application.updateUI()
var result = databaseManager.executeStoredProcedure(currentcontroller.getServerName(),'{?=call "dba"."backup"(?)}',argArray,iArray,0)
application.beep()
// Check if the backup is been performed otherwise show the Exception
var error = result.getExceptionMsg()
if ( error )
{
plugins.dialogs.showErrorDialog('DB Backup',error + '\nBackup not saved!','Ok')
backup_path = 'Error:\n' + error
}
else
{
// Recalculate the LOG size
globals.sintpro_backup_log_size = plugins.file.getFileSize(globals.sintpro_backup_current_log_file)
// Let's ask if they want to zip the backup file
zip = plugins.dialogs.showQuestionDialog('DB Backup','Backup saved succesfully to '+ backup_dir +
'\nDo you want to compress the Backup with Zip?','No','Yes')
if ( zip == 'Yes' )
{
forms.sintpro_backup_main.elements.progress_bar.string = "Compressing Backup..."
application.updateUI()
var zipdir = plugins.file.convertStringToJSFile(backup_dir)
var zipfile = plugins.it2be_tools.zip(zipdir.getAbsolutePath())
if ( zipfile )
{
var del = plugins.file.deleteFolder(zipdir.getAbsolutePath(),false)
}
}
// We finish
application.beep()
plugins.dialogs.showInfoDialog('DB Backup','Backup complete','Ok')
}
// Reset the progress bar
forms.sintpro_backup_main.elements.progress_bar.string = ""
application.updateUI()
cd C:\PROGRA~1\SERVOY\sybase~1\win32\
C:\PROGRA~1\SERVOY\sybase~1\win32\dbbackup.exe -y -c "uid=dba;pwd=sql;dbn=contacts" C:\PROGRA~1\SERVOY\backups\monday
C:\PROGRA~1\SERVOY\sybase~1\win32\dbbackup.exe -y -c "uid=dba;pwd=sql;dbn=holders" C:\PROGRA~1\SERVOY\backups\monday
C:\PROGRA~1\SERVOY\sybase~1\win32\dbbackup.exe -y -c "uid=dba;pwd=sql;dbn=log_data" C:\PROGRA~1\SERVOY\backups\monday
C:\PROGRA~1\SERVOY\sybase~1\win32\dbbackup.exe -y -c "uid=dba;pwd=sql;dbn=pdf_forms" C:\PROGRA~1\SERVOY\backups\monday
C:\PROGRA~1\SERVOY\sybase~1\win32\dbbackup.exe -y -c "uid=dba;pwd=sql;dbn=servoy_repository" C:\PROGRA~1\SERVOY\backups\monday
C:\PROGRA~1\SERVOY\sybase~1\win32\dbbackup.exe -y -c "uid=dba;pwd=sql;dbn=updates" C:\PROGRA~1\SERVOY\backups\monday
copy "C:\PROGRA~1\SERVOY\servoy.properties" C:\PROGRA~1\SERVOY\backups\monday
pg_dumpall -U username > /path/to/allMyData.backup
elyod_72 wrote:I am using MySQL.
I see from the other posts that I can do a backup of the database, and that is what I will do.
ngervasi wrote:
You can create a backup script on the server and trigger it using a small solution invoked by an headless client session.
Quick guidelines:
- Create a backup script that uses mysqldump to backup the selected database and store it on the server;
- Create a small solution with a method that triggers the backup script using the function "application.executeProgramInBackground()";
- Create a javascript page that invokes the above method in an headless client session;
- Open the javascript url from your solution to start the backup.
You can even pass parameters so you can build a standard backup system and pass the options (database name, structure only or data & structure, etc.) to the shell script.
Hope you get the picture.
Users browsing this forum: No registered users and 10 guests