In K2 Five you can archive reporting data in K2 by running some SQL scripts. The script archives data from the K2 database to another user-specified database, and includes verbose logging and information about the data it is currently processing. The script sends the logging information to the SQL output window, showing which table is currently being processed, how many records are affected, their timestamps and when a section is complete. This logging is not configurable and is not saved -- it is live output data which gives you a better idea of how the archiving is progressing. This is helpful for first-time archiving as it can take a long time and might appear stalled.
- You must have access to the K2 database and able to execute SQL statements against the database. You may need to enlist the assistance of your database administrator to run the scripts provided.
- You should make a backup of the K2 database before running the archive script.
- If you need assistance in archiving your K2 reporting data, please log a support ticket with Product Support.
Follow the steps below to create the necessary archive scripts and to execute the archive script.
- Download and extract the attached zip file.
- Run the mArchiveBackupLog.sql script against the K2 database. This script creates the mArchiveBackupLog Stored Procedure, which is used to output messages to the query window when you run the archive script.
- Run the mArchive_V1.6.sql script on the K2 database. This script creates the mArchive Stored Procedure which is used to archive data.
- If necessary, create a new archive database. (In the attached scripts, the archive database is called K2Archive). This is the target database and will be used as the repository for the archived data.
If you have archived K2 data before and want to append additional archived data to the existing archive database, you do not need to create a new database; just use the name of the existing archive database when you execute the archive script in step 8.
- Open the startArchiving.sql script.
- Change the value for @arcDB to the archive database name that you created in step 4.
- Specify a date range on the @FromDate and @ToDate. Data within this range will be archived to the target archive database.
- Run the startArchiving.sql script. Note that this script may take some time to complete, depending on the amount of data in your K2 Five environment. Use the Messages tab in the SQL query too to view the progress of the archiving operation. When the script is completed, you should see a message in the Messages window along the lines of Archiving completed successfully ALL DONE
Archiving in a K2 blackpearl-K2 Five upgrade scenario
If you are upgrading to K2 Five from a previous version of K2 with archived data, follow the steps below:
- If necessary, archive your existing environment's data using the applicable user interface for your version of K2. See KB000322: Archiving K2 blackpearl data
- Upgrade your environment to K2 blackpearl 4.7.
- Restore archived data using the Legacy Workspace
- Upgrade your environment to the latest version of K2 Five.
- Use the procedure described in Steps above to archive your data in K2 Five. If you have existing archive databases for previous versions of K2, do not use them, but instead create a new database for the K2 Five archived data.
- Only K2 workflow reporting data will be archived.
- The archive scripts will only archive data for workflows in Completed state. If any workflows in the specified period for archiving are in another state (such as Active, Running or Error), the reporting data for these workflow instances will not be archived.
- Archived records are permanently removed from the live K2 database and there is no way to restore those records back into the live database. Guidance on reporting on archived data will be provided at a future date.