SAP Sybase IQ 16.0 SP08 PL1 Point-in-Time Recovery July 2014
Table of Contents 1.0 Introduction... 2 2.0 Performing Point-in-Time Recovery... 2 3.0 Point-in-Time Recovery on Multiplex Servers... 8 4.0 References... 9 1
1.0 Introduction Point-in-time recovery restores all committed database operations prior to a specified point in time. A point in time can be expressed as a timestamp and timezone, or as a transaction log offset. This feature is available for new SAP IQ 16.0 SP08 databases and databases upgraded to 16.0 SP08. Point-in-time recovery extends, but does not replace standard backup and recovery operations. Point-in-time recovery always begins by restoring a database from a data backup, then replays all committed activity from the recovery logs that cover the entire time period between the backup and the specified point in time. Transactions that were in progress, but not committed are rolled back. 1 Point-in-time recovery differs from standard backup and restore operations. Point-in-time recovery cannot recover a database from a clean shutdown or crash via normal crash recovery. 1 2.0 Performing Point-in-Time Recovery The following are the steps for performing point-in-time recovery on an SAP IQ simplex configuration together with quick start example. This guide uses SAP IQ16.0 SP08 PL01 on a Windows machine. STEPS: 1) Follow the Quick Start guide for Windows for Creating a single server: http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01686.1600/doc/ht ml/wil1308589070482.html 2) Start the iqdemo database server (if not already started). start_iq @iqdemo.cfg iqdemo.db 3) If SCC is not already running, start a new command prompt, cd to %SYBASE%\SCC- 3_3\bin and enter: scc.bat In your browser, enter the address https://<scc-hostname>:8283/scc/ Log in using the credentials for sccadmin. 2
4) In SCC, on the Administration Console, click the drop-down arrow next to <localost>_iqdemo, choose Execute SQL. 5) Set IQ_POINT_IN_TIME_RECOVERY_LOGGING to ON by entering the following in the SQL Statements box and clicking Execute : SET OPTION PUBLIC.IQ_POINT_IN_TIME_RECOVERY_LOGGING = 'ON' 6) You may use ALTER DBSPACE to identify the directory where you want to archive the recovery logs: ALTER DBSPACE IQ_SYSTEM_LOG RENAME <new-directory-specification>/<fileprefix> SAP IQ saves the point-in-time recovery log in the same directory as the.db file by default. This command saves the log in another directory. The new-directoryspecification must point to an existing directory. For example: Create a subdirectory called DemoBackup in the MyIQDemo directory and execute: ALTER DBSPACE IQ_SYSTEM_LOG RENAME 'C:\Users\i840136\AppData\Local\Temp\I1399044207\MyIQDemo\DemoBackup' 7) Create a table in the demo database CREATE TABLE table1 (c1 INT, c2 INT, PRIMARY KEY (c1)) 8) Insert some data into that table INSERT INTO table1 (c1, c2) VALUES (1, 11), (2, 22), (3, 33) 9) Select data from that table SELECT * FROM table1 3
10) Perform a data backup BACKUP DATABASE FULL to 'C:\Users\i840136\AppData\Local\Temp\I1399044207\MyIQDemo\DemoBackup\FU LL1' 11) Now perform some other operations on the database CREATE TABLE table2 (col1 INT, col2 INT, PRIMARY KEY (col1)) INSERT INTO table2 (col1, col2) VALUES (123, 123), (456,456) SELECT * FROM table2 12) Record the timestamp and the offset TS1: SELECT getdate() OFS1: SELECT db_property('lastcommitredopos') 4
13) Perform some more operations on the database INSERT INTO table2 (col1, col2) VALUES (10, 10) SELECT * FROM table2 14) Record the timestamp and offset again. 15) Now, we are going to restore the database to the point in time TS1. 16) Shut down the database. 17) Save a copy of the transaction log, iqdemo.log, to C:\Users\i840136\AppData\Local\Temp\I1399044207\MyIQDemo\DemoBackup\iqde mo_savelog.log 18) Start a utility server, a server that you can use to connect to the utility database. To do this, enter the following at the command prompt: start_iq -su mypwd -gd DBA -gm 1 -n my_server 5
NOTE: You must ensure that no other database server is running when you start this utility server. 19) Start dbisql and connect to the utility database. To do this, enter the following at the command prompt: dbisql -c "UID=DBA;PWD=mypwd;DBN=utility_db" 20) Create a directory in which to store the restored database. The syntax for doing this is: RESTORE DATABASE '< db_file >' [ FROM '< file-name >' <...> [ USING LOG PATH ' directory, [...]] RECOVER UNTIL [ TIMESTAMP <timestamptz> OFFEST <log-offset> ] KEY <key_spec> [ VERIFY COMPATIBILE ] You must restore from a full database backup prior to the point in time you wish to recover the database. You must also restore all incremental backups taken prior to the point in time you want to recover. After this, you can run the RESTORE DATABASE command with the point-in-time syntax extensions shown above. NOTE: You must always specify a timestamp that is later than the backup time of the data backup specified in the FROM clause of the RESTORE DATABASE command. Otherwise, the server would return an error. In this example: RESTORE DATABASE 'C:\Users\i840136\AppData\Local\Temp\I1399044207\MyIQDemo2\Restored\iqdemo_ restored.db' FROM 'C:\Users\i840136\AppData\Local\Temp\I1399044207\MyIQDemo2\DemoBackup2\FUL L1' RECOVER UNTIL TIMESTAMP '2014-07-25 13:40:46.289' //'TS1' USING LOG PATH 'C:\Users\i840136\AppData\Local\Temp\I1399044207\MyIQDemo2', 'C:\Users\i840136\AppData\Local\Temp\I1399044207\MyIQDemo2\DemoBackup2\iqd emo_savelog' 6
This method keeps the old database and creates a new one restored to the timestamp we specified. As an alternative to this, if you wish to replace the old database with this restored database, you can restore the database to the same folder as the old database. NOTE: You must ensure that you delete all.db,.iq,.log,.iqtmp and.iqmsg from the directory where you are restoring the database before executing the RESTORE DATABASE command. If the restore is successful, you should see something like this: 21) Shut down the utility server. 22) Start the iqdemo database normally: start_iq @iqdemo.cfg iqdemo.db 23) Connect to the database using dbisql and execute: SELECT * FROM table2 24) We expect the database to be restored to the point in time TS1, so we should see: You can also try restoring to a time right after the full backup was created but before table 2 was created. In this case, we would expect table 1, but not table 2, to be in the database. 7
3.0 Point-in-Time Recovery on Multiplex Servers 2 Point-in-time recovery is available on multiplex servers in release IQ 16.0 SP08 PL1. Release IQ 16.0 SP08 supports point-in-time recovery on simplex only. 1 Here are some things to note when performing point-in-time recovery on Multiplex server configurations: Point in time recovery logging only becomes fully enabled when the data backup begins. On multiplex servers, all servers must be shut down during first data backup to enable point-in-time recovery logging. Shutdown all secondary nodes first. Allow some time to let the coordinator release all global free list allocations, then shutdown the coordinator. Start the coordinator only to perform the backup. After the backup is complete, synchronize all and restart all secondary nodes. In general, setting the POINT_IN_TIME_RECOVERY_LOGGING option to OFF disables point-in-time recovery immediately. Point-in-time recovery logging will be disabled during the following multiplex configuration changes: - Multiplex failover - Simplex to multiplex conversion - Multiplex to simplex conversion To re-enable point-in-time recovery after multiplex configuration changes, shut down all secondary nodes. Allow some time to let the coordinator release all global free list allocations, then shutdown the coordinator. Restart the coordinator or new failover coordinator, then use the ALTER DBSPACE IQ_SYSTEM_LOG RENAME command to rename the point-in-time recovery log. Perform a full data backup. Synchronize and restart all secondary nodes. 2 As we saw in step 6 above, by default, SAP IQ saves the point-in-time recovery log in the same directory as the.db file. To save the log in another directory, we use: ALTER DBSPACE IQ_SYSTEM_LOG RENAME ' new-directory-specification/file-prefix ' The new-directory-specification must point to an existing directory. If point-in-time recovery logging is active, using this command with a new-directory-specification, opens a new log at the new location. For multiplex servers, this directory must reside on a shared file system and be writable by all multiplex nodes. On multiplex servers, when executing the RESTORE DATABASE statement (as in step 20 above), use the current transaction log from the coordinator node. Do not include 8
transaction logs from secondary nodes. Including transaction logs from secondary nodes causes point-in-time recovery to fail, and return a Files are missing for Point-in-time- Recovery error. To restore a database on multiplex to a different location as a part of point-in-time recovery: 1. Shut down the original coordinator. 2. Save the coordinator transaction log to /demo/savelog. 3. Use the coordinator server s name with the single-node and override flags -iqmpx_sn 1 -iqmpx_ov 1 to start the utility database from the coordinator server directory. 4. Drop the original database. 5. Perform point-in-time recovery and specify the new database location: RESTORE DATABASE '<new-location>/iqdemo.db' FROM '/demo/databackup/full1' RECOVER UNTIL TIMESTAMP '<TS1>' USING LOG PATH '/demo/pitrlog/', /demo/savelog 4.0 References 1 http://help.sap.com/saphelp_iq1608_iqnfs/helpdata/en/a8/881a8584f210158e6884e70ac09c 68/content.htm 2 http://help.sap.com/saphelp_iq1608_iqnfs/helpdata/en/2a/b05c1b1a9641789d280993267abf 51/content.htm 9
Copyright Copyright 2014 SAP AG. All rights reserved No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iseries, pseries, xseries, zseries, eserver, z/vm, z/os, i5/os, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.