1

I want to have one folder in which I will store data which needs to be queried as fast as possible and the disk makes me wait a lot even it is SSD. On the other hand I have to store it permanently. I may made compromise which is that the data can be stored on the disk periodically (automatically!). I have UPS power supply so if the power gone I will not (eventually) lose the data.

Thanks.

"Your question has been identified as a possible duplicate of another question. If the answers there do not address your problem, please edit to explain in detail the parts of your question that are unique."

I do not found any information on how to configure auto save of the data to persistent storage, periodically.

Another requirement: on boot I would like the data from the persistent storage to get back on the RAM folder/partition.

Complete solutions will be highly appreciated!

daffr32
  • 13

1 Answers1

3
  1. Create a RAM disk

As described here you can make a RAM disk

mkdir -p /media/nameme
mount -t tmpfs -o size=2048M tmpfs /media/nameme/
  1. Copy last backup into RAM disk

    cp -ru /source/path /destination/path

Where source/path is the location of the backup-data, and /destination/path is the RAM disk location

Note: The same script which runs on boot and execute Create a RAM disk can also copy the data from the backup-folder into the RAM disk.

  1. auto save periodically the data on persistent storage:

You can create a simple script which will copy the content of this RAM disk once a period of time (minute/hour/etc) using a cron tab See here how to set a cron-tab.

crontab -e

running a copy/backup command every 15 minutes:

*/15 * * * * /path/to/command
  1. Copy command:

The command might be something like:

cp -ru /source/path /destination/path

-r -recursive

-u --update - copy only when the SOURCE file is newer than the destination file or when the destination file is missing

Yaron
  • 13,453