Sample Usage Scenarios

Overview

This section provides examples of potential backup scenarios and how to restore them. All of the scenarios use Sunday, February 3, 2016, as the starting date for the backup cycle. The weekly schedule includes the following backups:
  • a full backup of the server domain Test every Sunday at 23:30
  • an incremental backup of the domain at 23:30 on the remaining days of the week
One scenario shows how to perform both the full system backup and the incremental backups with spdsbkup. Another shows how to perform the full system backups with an operating system full backup utility and the incremental backups with spdsbkup.
Restore examples show how to restore a single server table, a server domain, and server indexes.
All of the examples use the command-line interface. For an example of how spdsbkup and spdsrstr are submitted from PROC SPDO, see Using PROC SPDO to Back Up and Restore Tables.

Performing Full and Incremental Backups with spdsbkup

This scenario uses spdsbkup to perform a full backup of your domain once a week, and to perform incremental backups the rest of the week. The incremental backups also fully back up any newly created tables. The backups are performed on a server domain named Test.
  1. On Sunday, February 3, 2016, at 23:30, issue the following spdsbkup command to do a full backup of the domain:
    spdsbkup -full -a -d test -h spdsname -s 5150 -f backup
    In the command, the following occurs:
    • The -full option specifies to perform a full backup.
    • The -a option specifies to include the domain ACL files in the backup.
    • The -d option specifies the domain to back up.
    • The -h option specifies the name server host.
    • The -s option specifies the name server port number.
    • The -f option specifies the prefix to use for the backup data file.
    The backup creates the backup data file backup_BK_05Feb2006_233000.0.0.0.spds9 and the backup table of contents file backup_TC_03Feb2016_233000. The backup file contains the full SPD Server backup for each table and for any ACL files in the domain. The table of contents file contains information about each table that was backed up.
  2. Archive the SPD Server backup file and the source that are in the table of contents file into a SAS table of contents table.
  3. On Monday night through Saturday night, use this spdsbkup command to perform incremental backups:
    spdsbkup -a -d test -h spdsname -s 5150 -f backup
    In this command, the following occurs:
    • The spdsbkup command is specified without the -full or -inc options to let the utility determine whether a full or incremental backup is appropriate for each table in domain Test.
    • The -a option specifies to include the domain ACL files in the backup, in case there are changes to it.
    • The -d option identifies the domain.
    • The -h and -s options identify the name server.
    • The -f option identifies the prefix of the target backup file. Use the same prefix that you used for the full backup. Although the same filename prefix is specified each night, spdsbkup saves each night's backup to a different file and appends the date and time of the backup to the filename.
    The command performs incremental backups of tables that were previously backed up, performs a full backup of tables that were created after the previous night's backup, and backs up any ACL files that are in the domain.
  4. Archive the incremental data file and source in the table of contents file into a SAS table of contents table.

Using a System Utility to Perform Full Backups

This scenario performs a full system backup of the domain Test by using operating system utilities once a week. It then uses SPD Server to perform a domain back up on the remaining nights.
Advantages to using system full backups over the SPD Server utility to do a full backup are as follows:
  • A system utility does not parse the data set. Therefore, this type of backup usually runs faster than the SPD Server utility when you are doing a full backup.
  • System utilities often write directly to tape storage media. In contrast, the SPD Server utility first writes backup data to a file on the hard drive, and then the backup file is usually backed up to tape.
  1. On Sunday, February 3, 2016, at 23:30, run the SPD Server list utility SPDSLS with the -L option to produce a listing of the tables that belong to the domain Test.
    spdsls -l -a <physical_path_of_domain> 
  2. Perform the full backup with the system utility.
  3. On Monday, February 4, 2016, at 23:30, run spdsbkup to perform the incremental backups as follows:
    spdsbkup -d test -h spdsname -s 5150 -t 02/04/2008:23:30:00 -f backup 
    In the command, the following occurs:
    • The spdsbkup command is specified without the -full or -inc options to let the utility determine whether a full or incremental backup is appropriate for each table in domain Test.
    • The -d option identifies the domain.
    • The -h and -s options identify the name server.
    • The -t option sets the last full backup date to the previous night for the Test tables. The utility performs an incremental backup of tables that have changed since the last full system backup. And it performs a full backup of tables that were created after the last full system backup was performed.
    • The -f option specifies a prefix for the target backup file.
    The utility creates the backup data file backup_BK_04Feb2016_233000.0.0.0.spds9 and a backup table of contents file backup_TC_04Feb2016_233000. The backup file contains incremental changes for tables that were modified after 23:30:00 on February 3, 2016, and full backups of tables created after 23:30:00 on February 4, 2016. Only the tables that were modified or created since the date specified in the -t option are included in the backup file. The table of contents file contains information about each table that was either incrementally or fully backed up.
  4. Archive the SPD Server backup file and source in the table of contents file into a SAS table of contents table.
  5. On Tuesday night through Saturday night, use the SPD Server backup utility to do incremental backups of previously backed up tables and full backups of the newly created tables with the following command:
    spdsbkup -d test -h spdsname -s 5150 -f backup
    In the command, note that a last full backup date is not specified for the remaining week's incremental backups. The SPD Server backup utility performs incremental backups of tables that were previously backed up and full backups of tables that were created since the previous night's backup. Although the same filename prefix is specified each night, spdsbkup saves each night's backup to a different file and appends the date and time of the backup to the filename.
  6. Archive the incremental data file and source in the table of contents file into a SAS table of contents table.

Restore a Single SPD Server Table

Use the following steps to restore a table that was accidentally deleted from the domain Test on Friday, February 8, 2016.
  1. If the table was backed up fully by the operating system backup utility, use the system restore utility to restore the table. (Restore the table to its last full backup image, which was taken on February 3, 2016.) If the table was backed up fully by the spdsbkup, skip this step.
  2. Run a SAS query on the backup table of contents table. In this example, the table is named Bkup.toc.
    select bk_file from foo.bkup_toc
    where domain = "test"
    and table = "results"
    and dttime >= '03Feb2016:23:30:00'd; 
    The query results indicate which SPD Server backup files are required to restore the table to its last full backup state.
  3. Gather the archived SPD Server backup files and any extensions that are required to restore the table.
  4. Run spdsrstr on each sequential SPD Server backup file to restore the table. The order runs from the oldest backup date to the most recent backup date. The example table was backed up fully using the SPD Server backup utility on Sunday, February 3, 2016. The table was then backed up incrementally on Tuesday, February 5, and on Thursday, February 7. The following order of the statements is required to restore the table:
    spdsrstr -d test -h spdsname -s 5150 -f backup_BK_03Feb2016_233000.0.0.0.spds9 
    results
    
    spdsrstr -d test -h spdsname -s 5150 -f backup_BK_05Feb2016_233000.0.0.0.spds9 
    results
    
    spdsrstr -d test -h spdsname -s 5150 -f backup_BK_07Feb2016_233000.0.0.0.spds9 
    results
    
    In the commands, note the following:
    • Each command specifies a different backup filename in the -f option. The files are uniquely identified by date.
    • “Results” is the name of the table that is being restored.
    Tip
    You can also use the -e option of spdsrstr and restore all of the files with one command:
    spdsrstr -d test -h spdsname -s 5150 -e backup results 
    Note: When you restore a single table, you do not need to restore the ACL files, because they were not deleted.

Restore an SPD Server Domain

Use the following steps to restore a server domain named Test. This domain was lost due to a system media failure that occurred on Friday, February 15, 2016.
  1. If the domain was backed up fully using the system backup utility, use the system restore utility to restore the domain Test to its state at the last full backup date of February 10, 2016. If the domain was backed up fully using the SPD Server utility, then skip this step.
  2. Use SAS to run a query on the backup table of contents table Bkup_toc.
    select bk_file from foo.bkup_toc
    where domain = "test"
    and dttime >= '10FEB2016:23:30:00'd; 
    The query results identify which SPD Server backup files are required to restore the domain.
  3. Gather the archived SPD Server backup files required to restore the domain.
  4. Use the SPD Server restore utility to restore the domain Test:
    spdsrstr -aforce -d test -h spdsname -s 5150 -e backup
    The -aforce option causes the domain ACLs to be updated for each restore file. Therefore, the latest backup of the ACLs is restored.

Back Up and Restore Table Indexes Using SPD Server Full Backups

When you perform an SPD Server full backup of a table, spdsbkup does not save the index data. It saves only the information necessary to re-create the indexes when the table is restored. Therefore, when you back up table indexes, the information that is saved does not require additional overhead or a lot of additional space.
If you must fully restore a table later, you can use one of the following two methods to restore the indexes:
  • spdsrstr can re-create the indexes when the table is created (default behavior). In this method, the index is updated dynamically as each observation is added to the table.
  • Use the -n option with spdsrstr. The -n option suppresses the creation of an index. After the table is fully restored, you can use PROC DATASETS or PROC SQL to re-create the indexes.

Back Up and Restore Table Indexes Using System Full Backups

Restoring the Index Dynamically

To restore a table’s index from a full system backup dynamically, you must include the table index files in the full backup and restore of the table. To determine which index files to include, use spdsls with the -i index option. The output lists component files for each table in the domain that is to be fully backed up.
When you restore a table, you must first restore the table metadata, data, and index files from the last full backup archive. Then use spdsrstr to perform incremental restores. As the tables are restored, the indexes are dynamically updated to include any new or modified records.
This method trades the additional resources that are required for full backup of the table index files, which can be very large, against the potentially short time that might be required to restore them. You can restore indexes for a table that has not had any incremental changes after the system full backup by using a system full restore.

Re-creating the Index after the Table Is Restored

If you choose to re-create the index after the table is restored, you do not need to include the index files in the full backup of the table. When you run spdsls to list the component files for each table in the domain that you intend to back up, omit the -i index option. The spdsls utility includes a list in the output that excludes index files.
Note: If you do not save index information, you can experience problems when you attempt to fully restore the table. The table's metadata contains information about the index files that might be missing or out of date. As a result, the metadata no longer mirrors the contents of the table.
Before you can perform an incremental restore of the table, you must first repair the table metadata. To repair the metadata, use PROC DATASETS to modify the table and delete all of the indexes. Then run spdsrstr to restore the table. After the table is restored, use PROC DATASETS again to modify the table and create the indexes.
Last updated: February 3, 2017