Skip to main content
Logo

Bulk unarchive

If you self-host Contensis and want to unarchive a large number of content items you may find it easiest to use an SQL script to do this as a bulk action. 

Note: We highly recommend you have a backup of your CMS database before executing any of the following queries in a production system.

By file type and location

To unarchive all .pdfs in a specified folder:

DECLARE @c_id Integer
DECLARE @F_id Integer
DECLARE @cv_id Integer
DECLARE @c_ct_id Integer
DECLARE @cv_label Nvarchar(255)

DECLARE db_cursor CURSOR FOR  
 
select c_id, c_f_id, cv_id, c_ct_id, cv_label from cv_contentversion
join c_content
on cv_contentversion.cv_c_id = c_content.c_id
WHERE
C_CT_ID = 21 -- pdf
AND C_F_ID = [Add your folder id here]

OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @c_id, @f_id, @cv_id, @c_ct_id, @cv_label
 
WHILE @@FETCH_STATUS = 0   
BEGIN   
    
    set @f_id = Replace(@f_id, '-', '')

 --@ContentID int,
 --@ContentVersionID int,
 --@ContentTypeID int,
 --@Label nvarchar(255), 
 --@F_ID int, 
 --@US_ID int


 -- COMMENT IN BELOW WHEN READY --

       -- exec up_RestoreArchivedContent @c_id, @cv_id, @c_ct_id, @cv_label, @f_id, 1

       print @c_id 
       print @f_id      
    print @cv_id
    print @cv_label
 
       FETCH NEXT FROM db_cursor INTO @c_id, @f_id, @cv_id, @c_ct_id, @cv_label
END   
 
CLOSE db_cursor   
DEALLOCATE db_cursor

If you want to unarchive other or multiple asset file types, you can include the relevant asset type id(s) in this line of the SQL script:

C_CT_ID = 21

Webpages by location

To unarchive all webpages in a specified folder:

DECLARE @wp_id Integer
DECLARE @F_id Integer
DECLARE @wpv_id Integer

DECLARE @wpv_label Nvarchar(255)

DECLARE db_cursor CURSOR FOR  
 
select wp_id, wp_f_id, wpv_id, wpv_label from wpv_webpageversion
join wp_webpages
on wpv_webpageversion.wpv_wp_id = WP_Webpages.wp_id
WHERE
wp_f_id = [Add your folder id here]

OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @wp_id, @f_id, @wpv_id, @wpv_label
 
WHILE @@FETCH_STATUS = 0   
BEGIN   
    
    set @f_id = Replace(@f_id, '-', '')

    --@ContentID int,
    --@ContentVersionID int,
    --@ContentTypeID int,
    --@Label nvarchar(255), 
    --@F_ID int, 
    --@US_ID int

    -- COMMENT IN BELOW WHEN READY --

    -- exec up_RestoreArchivedContent @wp_id, @wpv_id, 0, @wpv_label, @f_id, 1

    print @wp_id 
    print @f_id      
    print @wpv_id
    print @wpv_label
 
    FETCH NEXT FROM db_cursor INTO @wp_id, @f_id, @wpv_id, @wpv_label

END   
 
CLOSE db_cursor   
DEALLOCATE db_cursor