My goal is to have a certain directory to be available as tmpfs. There will be some modifications during server uptime in this dir and those modifications must be synced to non-tmpfs persistent dir on HDD over rsync.

After server boot the latest version from non-tmpfs persistent dir must be moved to tmpfs and rsync syncing to be started.

I'm afraid that rsync will erase non-tmpfs backup if tmpfs dir will be empty..

I'm doing it in this way right now:

  1. create tmpfs partition in /etc/fstab
  2. cat /etc/rc.local (pseudocode)

    delete "tmpfs rsync" cronjob from /var/spool/cron/crontabs if there is any

    cp -r /path/to/non-tmpfs-backup /path/to/tmpfs/dir

    append /var/spool/cron/crontabs with "tmpfs rsync" cronjob

What do you think?

link|improve this question

62% accept rate
1  
When you need persistent data storage, tmpfs is probably the wrong file system to use. Also see serverfault.com/questions/43383/… – joschi Jul 17 '10 at 5:57
feedback

1 Answer

up vote 0 down vote accepted

Create some sort of seed file deep in your non-tmpfs directory and only rsync back to non-tmpfs if it exists (meaning the "boot" copy worked), so something like:

BOOT

mount /path/tmpfs
rsync -aq --delete /path/non-tmpfs/ /path/tmpfs/

CRON

if [ -f /path/tmpfs/some/deep/location/filesgood.txt ]; then
  rsync -aq--delete /path/tmpfs/ /path/non-tmpfs/
fi

It's not perfect but if you enhance that (look for 5 "cookie" files during cron if you want to in different directories, e.g.) it should be pretty safe.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.