Damon set scheduled backup job



1, Command line settings scheduled backup jobs

Configure the Archive Environment:

First install the stand-alone library on the virtual machine and initialize it,

Create archive and backup directories:

Create archive directory and backup directory

mkdir -p /home/dmarch /home/dmbak   

to grant authorization:

chown -R dmdba:dinstall /home/dmarch /home/dmbak 

1. Manually configure archiving:

Modify the dm.ini file to change ARCH_INI is set to 1

Configure the dmarch.ini file in the current directory

[ARCHIVE_LOCAL1]

ARCH_TYPE = LOCAL

ARCH_DEST =/home/dmarch

ARCH_FILE_SIZE = 1024

ARCH_SPACE_LIMIT = 2048

  After starting the instance, exit to put the database into the archive state.

2. To configure online archiving:

  Change the database to the mount configuration state

Configure local archiving:

ALTER DATABASE ADD ARCHIVELOG 'DEST =/home/dmarch, TYPE = local, FILE_SIZE = 1024, SPACE_LIMIT = 10240';

Open archive:

ALTER DATABASE ARCHIVELOG;

At this time, the configuration database is in OPEN status:

ALTER DATABASE OPEN;


  During online backup, pay attention to:

Close and re open the configured local archive, which will cause the loss of some logs in the archive file. An error will be reported when checking the continuity of the archive file during backup. In order to avoid errors, you need to call checkpo int(100) to actively refresh the checkpoint before this backup operation.

Create a job environment:

Job environment initialization

SP_INIT_JOB_SYS(1);

Destruction of working environment

SP_INIT_JOB_SYS(0);

Scheduled backup

Start regular backup, and conduct full backup every Saturday at 16:20, starting from 16:19 p.m. on August 28, 2021.

All ready:

call SP_CREATE_JOB('JOB_FULL_BAK_TIMELY',1,0,'',0,0,'',0,'Timed full standby');

call SP_JOB_CONFIG_START('JOB_FULL_BAK_TIMELY');

call SP_ADD_JOB_STEP('JOB_FULL_BAK_TIMELY', 's1', 6, '01010000/home/dmbak', 1, 3, 0, 0, NULL, 0);

call SP_ADD_JOB_SCHEDULE('JOB_FULL_BAK_TIMELY', 's2', 1, 2, 1, 64, 0, '16:20:50', NULL, '2021-08-28 16:19:50', NULL, '');

call SP_JOB_CONFIG_COMMIT('JOB_FULL_BAK_TIMELY');

Incremental backup:
Start incremental backup every Saturday at 16:20 p.m., starting from 16:19 p.m. on August 28, 2021.

call SP_CREATE_JOB('JOB_INCREMENT_BAK_TIMELY',1,0,'',0,0,'',0,'Incremental backup');

call SP_JOB_CONFIG_START('JOB_INCREMENT_BAK_TIMELY');

call SP_ADD_JOB_STEP('JOB_INCREMENT_BAK_TIMELY', 's3', 6, '11010000/home/dmbak|/home/dmbak', 1, 3, 0, 0, NULL, 0);

call SP_ADD_JOB_SCHEDULE('JOB_INCREMENT_BAK_TIMELY', 's4', 1, 2, 1, 64, 0, '16:20:00', NULL, '2021-08-28 16:19:00', NULL, '');

call SP_JOB_CONFIG_COMMIT('JOB_INCREMENT_BAK_TIMELY');

 ​​​​

Set periodic deletion of backups
  The backup is deleted regularly and executed once a day. The execution time is 16:22:58, starting from August 28, 2021.

call SP_CREATE_JOB('JOB_DEL_BAK_TIMELY',1,0,'',0,0,'',0,'Delete backup set');
call SP_JOB_CONFIG_START('JOB_DEL_BAK_TIMELY');
call SP_ADD_JOB_STEP('JOB_DEL_BAK_TIMELY', 's5', 0, 'SF_BAKSET_BACKUP_DIR_ADD(''DISK'',''/home/dmbak'');SF_BAKSET_REMOVE_BATCH (NULL, now(), NULL, NULL);', 3, 3, 0, 0, NULL, 0);
call SP_ADD_JOB_SCHEDULE('JOB_DEL_BAK_TIMELY', 's6', 1, 1, 1, 0, 0, '15:58:08', NULL, '2021-08-28 16:22:00', NULL, '');
call SP_JOB_CONFIG_COMMIT('JOB_DEL_BAK_TIMELY');

View job information

 select ID,NAME,ENABLE,USERNAME,CREATETIME,VALID,DESCRIBE from SYSJOB.SYSJOBS;

View step information

select ID,NAME,JOBID,SEQNO,TYPE,COMMAND from SYSJOB.SYSJOBSTEPS;

View scheduling information

select ID,NAME,JOBID,ENABLE,TYPE,FREQ_INTERVAL,FREQ_SUB_INTERVAL,STARTTIME,VALID,DESCRIBE from SYSJOB.SYSJOBSCHEDULES;

View job execution

select NAME,START_TIME,END_TIME,ERRCODE,ERRINFO from SYSJOB.SYSJOBHISTORIES2 order by START_TIME desc;








2, Graphically create scheduled backup jobs








Create the proxy environment first

  Start setting after creating a new job

In the job step, click add at the bottom right to create a new job step.

After confirmation, create a new job schedule.

At this time, the scheduled full backup job is set successfully:

The incremental backup job steps are similar to the above, but the base backup path should be added.

Set jobs to delete backup sets on a regular basis:

Add sql statement in job scheduling:

SF_BAKSET_BACKUP_DIR_ADD(''DISK'',''E:\dmbak'');SF_BAKSET_REMOVE_BATCH (NULL, now()-5, NULL, NULL);

 

  View job

For more information, please go to Dameng technology community: https://eco.dameng.com

Tags: Database

Posted on Tue, 28 Sep 2021 04:38:27 -0400 by matrixd