Backup Windows Server with TrueCrypt / VeraCrypt
TrueCrypt is considered dead these days, but back when it was trusted this is a script I wrote to backup Windows Server (2008 and above) with TrueCrypt. It uses a loopback VHD (loopback file/drive) on a removable USB harddrive that it RAW formatted with TrueCrypt. That TrueCrypt volume then contains a large VHD file to the size of your backup volume.
How to configure it:
- Save the bat file on your server
- Format a (USB?) drive as a RAW TrueCrypt volume
- Mount the TrueCrypt partition
- Create a VHD volume with the filename: z:Backups.vhd within the TrueCrypt volume
- Mount the VHD volume as Z Drive
- Configure Windows Server Backup to use the Z Drive as a backup destination
- Unmount the VHD Volume
- Unmount the TrueCrypt volume
- Create the directories: C:backupscripts
How to use it:
With the above completed:
- Configure a scheduled task to run 10 minutes before your nightly backup job to run the backup script (Mount-truecrypt.bat)
- Eg. If your backup is to run at 11pm, configure the script to run at 10:50pm.
- Then after your backup finishes execute another scheduled task to UNmount the VHD and TrueCrypt volume (UNmount-truecrypt.bat)
Your done!
P.S. I’m not actually sure if this works with VeraCrypt but I think they have the same command line flags…. :-P
:: Truecrypt backup script written by Campbell McKenzie - www.cammckenzie.com :: ================================= :: == START Mount-truecrypt.bat == :: ================================= :: "Auto" mount the RAW TrueCrypt disk as drive Z: password 1234 eventcreate /L Application /T INFORMATION /SO Backup /ID 666 /D "Attempting to mount backup disks..." CD C:\Program Files\TrueCrypt TrueCrypt.exe /auto devices /q /lZ /p 1234 if '%errorlevel%' EQU '0' ( eventcreate /L Application /T SUCCESS /SO Backup /ID 666 /D "RAW Disk mounted on Z:\ " goto MountVHD ) else ( goto ERROR-TC ) :MountVHD :: Perform directory listing for Truecrypt Bugs dir z:\ > nul :: Create the scriptlet cd C:\backup\scripts echo sel vdisk file="Z:\Backups.vhd" >mount.diskpart echo attach vdisk >> mount.diskpart echo select partition 1 >> mount.diskpart echo assign letter=X >> mount.diskpart :: Run the cmdlet diskpart /s mount.diskpart if '%errorlevel%' EQU '0' ( eventcreate /L Application /T SUCCESS /SO Backup /ID 666 /D "Loopback VHD Disk mounted on X:\ - Mount Completed" goto TidyUp ) else ( goto ERROR-DP ) :TidyUp del /q mount.diskpart EXIT 0 :ERROR-TC eventcreate /L Application /T ERROR /SO Backup /ID 666 /D "TrueCrypt Mount Failed..." EXIT 1 :ERROR-DP eventcreate /L Application /T ERROR /SO Backup /ID 666 /D "Loopback VHD Disk mount Failed..." EXIT 1 :: REF: http://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/ :: =============================== :: == END Mount-truecrypt.bat == :: ===============================
:: ================================== :: == START UNmount-truecrypt.bat == :: ================================== :: UnmountVHD.cmd eventcreate /L Application /T INFORMATION /SO Backup /ID 667 /D "Attempting to unmount backup disks..." cd C:\backup\scripts echo sel vdisk file="z:\Backups.vhd" >unmount.diskpart echo detach vdisk >>unmount.diskpart :: Run the cmdlet diskpart /s unmount.diskpart if '%errorlevel%' EQU '0' ( eventcreate /L Application /T SUCCESS /SO Backup /ID 667 /D "Loopback VHD Disk unmounted successfully..." goto UnmountTrueCrypt ) else ( goto ERROR-DP ) :: Unmount the RAW disk :UnmountTrueCrypt "C:\Program Files\TrueCrypt\TrueCrypt.exe" /d /q /s if '%errorlevel%' EQU '0' ( eventcreate /L Application /T SUCCESS /SO Backup /667 /D "RAW Disk unmounted successfully - Unmount Completed" goto TidyUp ) else ( goto ERROR-TC ) :TidyUp del /q unmount.diskpart EXIT 0 :ERROR-TC eventcreate /L Application /T ERROR /SO Backup /ID 666 /D "TrueCrypt Unmount Failed..." EXIT 1 :ERROR-DP eventcreate /L Application /T ERROR /SO Backup /ID 666 /D "Loopback VHD Disk Unmount Failed..." EXIT 1 :: ================================== :: == END UNmount-truecrypt.bat == :: ==================================
Run MySQL in the foreground
Well actually it’s not in the foreground but to a log file, but if you tail / follow the logfile you could pretend it was the foreground :-)
mysqld_safe --log-error=/var/log/mysql.err
And perhaps you have imported a database for forensic investigation and you don’t know the database password, you can just skip the authentication:
mysqld_safe --skip-grant-tables --log-error=/var/log/mysql.err
sec_error_ca_cert_invalid - Firefox and SSL certificates
Seems that Firefox v31 and later has decided to remove access to sites encrypted with self signed certificates by default!
Anyway to resume some form of normality modify your “about:config” in the firefox address bar
Search for “security.use_mozillapkix_verification” and set it to “false”
That should do it.
Adobe Acrobat Reader 11.0.06 offline installer link
These posts were pretty popular when I used to do them so I’ll try keep them updated:
Download the full Adobe Acrobat Reader installer EXE here:
ftp://ftp.adobe.com/ … beRdr11006_en_US.exe
No bloatware either!
SBS 2008: Huge sharepoint_config ldf file - not reducing in size!
Recently had a client with an unused Sharepoint instance and very little free disk space left.
A review of the file system show that xxxxxxxx was 51GB!! … The server had 17GB free disk space. I knew it was a SQL log that hadn’t been truncated. But with little free disk space left and the fact that it was unused sharepoint - I was happy to discard the logs without backing them up.
I used the following commands to do so:
BACKUP LOG [database] WITH NO_LOG; GO ALTER DATABASE [database] SET RECOVERY SIMPLE; GO use [database]; GO DBCC SHRINKFILE([database_log],2); GO ALTER DATABASE [database] SET RECOVERY FULL; GO
Success 67GB Free!!!