docs.datacontroller.io/docs/restore.md

32 lines
1.8 KiB
Markdown
Raw Normal View History

2024-05-02 13:09:17 +00:00
---
layout: article
title: Data Restore
description: How to restore a previous version of a Data Controller table
2024-05-02 15:36:36 +00:00
og_image: https://docs.datacontroller.io/img/restore.png
2024-05-02 13:09:17 +00:00
---
# Data Restore
For those tables which have [Audit Tracking](/dcc-tables/#audit_libds) enabled, it is possible to restore the data to an earlier state!
2024-05-02 15:42:46 +00:00
Simply open the submit to be reverted (via HISTORY or the table INFO/VERSIONS screen), and click the red **REVERT** button. This will generate a NEW submission, containing the necessary reversal entries. This new submission **must then be approved** in the usual fashion.
2024-05-02 13:09:17 +00:00
2024-05-02 15:36:36 +00:00
![](/img/restore.png)
2024-05-02 15:55:50 +00:00
This approach means that the audit history remains intact - there is simply a new entry, which reverts all the previous entries.
2024-05-02 15:43:57 +00:00
## Caveats
2024-05-02 13:09:17 +00:00
Note that there are some caveats to this feature:
2024-05-03 12:42:41 +00:00
- User must have EDIT permission
- Table must have TXTEMPORAL or UPDATE Load Type
- Changes **outside** of Data Controller cannot be reversed
2024-05-02 13:09:17 +00:00
- If there are COLUMN or ROW level security rules, the restore will abort
2024-05-02 15:42:46 +00:00
- If the model has changed (new / deleted) columns the restore will abort
2024-05-02 13:09:17 +00:00
2024-05-02 15:36:36 +00:00
## Technical Information
2024-05-02 15:55:50 +00:00
The restore works by undoing all the changes listed in the [MPE_AUDIT](/tables/mpe_audit/) table. The keys from this table (since and including the version to be restored) are left joined to the base table (to get current values) to create a staging dataset, and then the changes applied in reverse chronological order using [this macro](https://core.sasjs.io/mp__stripdiffs_8sas.html). This staging dataset is then submitted for approval, providing a final sense check before the new / reverted state is applied.
2024-05-02 15:36:36 +00:00
2024-05-02 15:40:52 +00:00
Source code for the restore process is available [here](https://git.datacontroller.io/dc/dc/src/branch/main/sas/sasjs/services/editors/restore.sas).