Ok so nothing you do on a tmpfs is not going to persist after a restart. That's because a tmpfs is temporary and only exists in the RAM. Anything that needs to be on a tmpfs for the system to run must be created every time the system boots. Most processes that use /var do this but some it seems such as anacron and cups-pdf do not.
To fix this you have to create a script that creates these directories every time the system starts. Copy the below into a text file, save it and make it executable.
#!/bin/bash
# Script to create required directories in tempfs /var (that are not otherwise created)
# Thanks to http://blog.philippklaus.de/2011/02/ssd-optimizations-on-linux/ for the list below :-)
for dir in apparmor apt ConsoleKit cups dist-upgrade fsck gdm installer news ntpstats samba speech-dispatcher unattended-upgrades; do
if [ ! -d /var/log/$dir ] ; then
mkdir /var/log/$dir
fi
done
for dir in cups-pdf anacron; do
if [ ! -d /var/spool/$dir ] ; then
mkdir /var/spool/$dir
fi
done
Next you need to make this script run every time the system starts by adding a line to /etc/rc.local
I called my script "make_required_dirs_on_tempfs.sh" so I just add the following line to the rc.local file. Put it at the end but above the "exit 0" command.
/PATH_TO_SCRIPT/make_required_dirs_on_tempfs.sh
I saved my script in "/mnt/data/config/scripts/start-stop" and so my /etc/rc.local file looks like this:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
#if [ -d "/var/cache/apt/archives" ]; then echo "/var/cache/apt/archives exists"; else mkdir /var/cache/apt/archives; fi || die "Command failed: mkdir /var/cache/apt/archives"
/mnt/data/config/scripts/start-stop/make_required_dirs_on_tempfs.sh
exit 0