The CreatorCon Call for Content is officially open! Get started here.

We need to be able to mass restore archived records...is that possible? If so, how?

AllenTschumper
Kilo Contributor

We are moving, or already have moved to a CSM instance of service now and are soon to retire our old instance (end of year),

Now we need to move old data over from the old instance.  I want to move our archived data.  I am finding that I need to restore the RITM data to be able to retain the variables on them.  If I don't restore, things do not work as needed.  

But really, I just want to know if there is a way to mass restore archived records and NOT have to do them one-by-one.  Which the latter is no feasible with having hundreds of thousands of records.  I am assuming we'd need a script.  

Anyone able to do this?

16 REPLIES 16

Can you use new GlideArchiveRestore().restore(gr2.sys_id); in a scoped application? It giving me below error:

find_real_file.png

Snowdevloper
Tera Expert

To restore records back man table fm_expense_lines from sys_archive_log  with the help of filter like created (sys_crerated) after 2020-05-03 
Note: For my case, the "sys_archvie_log" table is having crores of records  so that the reaon i don't have option to check restore from the "sys_archive_log" table.

I am trying with the fix script bit its now doing the restore

restoreRecords();
var archr = new GlideRecord('ar_fm_expense_line');
archr.addEncodedQuery("sys_created_on>javascript:gs.dateGenerate('2021-05-03','23:59:59')");
//archr.orderByDesc('number');
archr.query();
function restoreRecords() {

 

    var archiveGR = new GlideRecord('sys_archive_log');
    archiveGR.addEncodedQuery('to_table=ar_fm_expense_line^restored=NULL'); 
    archiveGR.query();
    while (archiveGR.next()) {
        new GlideArchiveRestore().restore(archiveGR.sys_id);
    }
}