8.3 Backing up the External Sybase Database Running on a Linux Server to a Network Location on a Remote Linux Machine

To back up the external Sybase database that is installed and running on a Linux server to a network location on a Linux machine, you need a local machine and a remote machine. The local machine is a Linux server with the external Sybase database installed. The remote machine is a Linux machine that has the network location to which you want to back up the database.

You can back up the database on a Linux machine by using any Linux share such as Samba share or an NFS share.

To back up the external Sybase database that is installed and running on a Linux server to a network location on a Linux machine by using Samba share:

  1. Create a Samba share on the remote machine:

    1. Create a user by entering the useradd user_name command at the command prompt.

    2. Log into the remote machine with the user name you created in Step 1.a, and set the password by using the passwd specify_the_password command.

    3. Create a directory to save the database backup.

      For example, create a directory with the name backup.

    4. Open the Samba server settings by running the yast2 samba-server command.

    5. Click the Shares tab, then click Add to specify the share name and the path to the backup directory you created in Step 1.c.

      For example, specify the share name as dbbackup.

    6. Select the dbbackup share, click Edit, then add the following attributes:

      • create mask = 0640

      • force user = user_name_created_in_Step 1.a

      • guest ok = yes

      • public = yes

      • wide links = no

      • writeable = yes

  2. Create a directory on the local machine.

    For example, create a directory with the name zenworks_dbbackup in /root.

  3. Mount the Samba share on the zenworks_dbbackup directory on the local machine by entering the following command at the command prompt:

    mount -t smbfs //IP_address of the remote_machine/share_name -o username=user_name_specified_in_Step1a,password=password_ specified_in_Step_1b local_directory_name_with_complete_path_created_in_Step2

    For example:

    mount -t smbfs //IP_address of the remote_machine/dbbackup -o username=user_name_specified_in_Step1a,password=password_ specified_in_Step_1b /root/zenworks_dbbackup

  4. Launch the DBISQL utility on the local machine. For more information, see Step 1 in the Section 8.1, Backing Up the External Sybase Database on a Windows or Linux Server.

  5. Decide whether you want to immediately back up the external Sybase database or to schedule the backup to run at a specific time. To back up the database immediately, continue with Step 5.a. To schedule the backup to run at a specific time, skip to Step 6.

    1. Stop the ZENworks Services on the ZENworks Servers in the Management Zone.

      1. Execute the following command at the server prompt:

        /opt/novell/zenworks/bin/novell-zenworks-configure -c Start

      2. Enter the number next to the Stop action.

    2. To immediately back up the external Sybase database to the network location on the remote machine, do one of the following:

      • Specify the following query in the SQL Statements section of the DBISQL utility:

        BACKUP DATABASE DIRECTORY ‘complete_path_of_the_backup_directory_on_database_server' TRANSACTION LOG TRUNCATE

        For example, execute the following query to back up the database to the /root/zenworks_dbbackup directory:

        BACKUP DATABASE DIRECTORY '/root/zenworks_dbbackup/' TRANSACTION LOG TRUNCATE

        You must manually archive the complete path of the database backup location that you specify in the query because you need to specify it if you want to change the database backup location at a later time.

      • Manually copy zenworks_zone_name.db and zenworks_zone_name.log from the database server to a required location on the remote machine.

        By default, the files are located in /var/opt/novell/zenworks/database/ on a Linux Sybase database server.

    3. Click Execute SQL Statement(s).

    4. Start the ZENworks Services on the ZENworks Servers in the Management Zone .

      1. Execute the following command at the server prompt:

        /opt/novell/zenworks/bin/novell-zenworks-configure -c Start

      2. Enter the number next to the Start action.

  6. To schedule the backup to run at a specific time every day or on specific days of a month:

    1. Execute the following query by specifying it in the SQL Statements section:

      CREATE EVENT backup_schedule_name
      
      SCHEDULE
      
      START TIME specify_the_schedule
      
      HANDLER
      
      BEGIN
      
      BACKUP DATABASE DIRECTORY ‘complete_path_of_the_backup_directory_on_database_server
      TRANSACTION LOG TRUNCATE
      
      END;
      

      While creating a database backup event, use the following guidelines:

      • The backup schedule name that you specify must be unique.

      • You must manually archive the backup schedule that you specify in the query because you need to specify it if you want to change the database schedule at a later time.

    2. Click Execute SQL Statement(s).

    Examples:

    • To back up the database at a 1:00 A.M. everyday to the /root/zenworks_dbbackup directory on Linux, execute the following query:

      CREATE EVENT ZENDBbackup
      
      SCHEDULE
      
      START TIME '1:00 AM' EVERY 24 HOURS   
      
      HANDLER
      
      BEGIN
      
      BACKUP DATABASE DIRECTORY '/root/zenworks_dbbackup/'
      
      TRANSACTION LOG TRUNCATE
      
      END;
      
    • To back up the database at a 1:00 a.m. on the first, second, third, and fourth day of the month to the /root/zenworks_dbbackup directory on Linux, execute the following query:

      CREATE EVENT ZENDBbackup
      
      SCHEDULE
      
      START TIME '1:00 AM' EVERY 24 HOURS ON (1,2,3,4)   
      
      HANDLER
      
      BEGIN
      
      BACKUP DATABASE DIRECTORY '/root/zenworks_dbbackup/'
      
      TRANSACTION LOG TRUNCATE
      
      END;
      
    • To back up the database to the /root/zenworks_dbbackup/day_of_the_week directory on Linux, execute the following query:

      CREATE EVENT ZENDBbackup
      
      SCHEDULE
      
      START TIME '1:00 AM' EVERY 24 HOURS   
      
      HANDLER
      
      BEGIN
      
      DECLARE backupDir varchar(256);
      
      DECLARE backup_stmt varchar(512);
      
      SET backupDir = DAYNAME(now());
      
      SET backup_stmt = 'BACKUP DATABASE DIRECTORY '|| '''/root/zenworks_dbbackup//' || backupDir || ''''|| ' TRANSACTION LOG TRUNCATE';
      
      EXECUTE IMMEDIATE backup_stmt;
      
      END;
      

According to the backup schedule, zenworks_zone_name.db and zenworks_zone_name.log are created in the network location on the remote machine (/root/zenworks_dbbackup). The backed-up database is stored in zenworks_zone_name.db. The result of the database backup is logged in zenworks_zone_name.log.

If you want to change the database backup location or the backup schedule at a later time, see Section 20.3, Changing the Backup Schedule and Location of the External Sybase Database Subsequent to the Initial Backup.