NOTE: THIS PROCESS IS DESTRUCTIVE – USE AT YOUR OWN RISK.
A nightmare for any Plone administrator.. When restoring your server from a backup or after an unexpected server failure – You receive a message such as below when trying to start your instance:
ZODB.FileStorage.FileStorage.CorruptedTransactionError: /opt/plone/zinstance/var/filestorage/Data.fs data record exceeds transaction record at 20055859
This is never good – Though there is a process to repair your database. I would note, however, that this method is destructive and will simply “skip” the corrupted transaction – You will likely encounter error loss but some data is better than no data..
Download the below script to your server and update with the path of your zinstance directory – Run the script, enterring the corrupted record number in the script when prompted, it will go through and truncate your database, skipping the corrupted entry.
Fix-corrupted-data-fs.sh
#!/bin/sh dir="/opt/plone/zinstance/var/" # Browse to Directory cd $dir # Delete any current repair attempts rm -f filestorage/Data.fs_ERR # Copy the current, corrupted database to a temporary location cp -p filestorage/Data.fs filestorage/Data.fs_ERR # Delete the current database index rm -f filestorage/Data.fs.index #diagnostic run - Start plone sudo -u plone_daemon ../bin/plonectl fg echo "" echo "................................................................" echo "Copy the corrupted record location from the launch above:" echo -n "put the number here:" read CISLO python<<_EOF f = open("filestorage/Data.fs", "ab") f.truncate($CISLO) f.close() _EOF # Copy backup to new Database, skipping corrupted record location dd if=filestorage/Data.fs_ERR of=filestorage/Data.fs.MISSING bs=1 skip=$CISLO # Fix file permissions chown -R plone_daemon:plone_group /opt/plone/zinstance/var/{blobstorage,filestorage}/ # Start Plone in Foreground mode again sudo -u plone_daemon ../bin/plonectl fg
Hopefully the corrupted transaction record will not have caused too much Damage to your plone instance and you can now browse to your instance once more.