1

I'm using tmpfs on my SD card for working with I/O intensive programs. From time to time (let's say once a day) I want that all data should write to SD card to be on the safe side in case of power failure (in backuped folder). Any idea how to do it?

4
  • cron would be my go to for such a task – Jaromanda X Mar 3 '20 at 8:23
  • Maybe I wasn't clear enough. I understand that part of creating a recurring task. But I don't know how to clear the ramdisk. – JanezKranjski Mar 3 '20 at 9:07
  • Not sure you can directly do this, as it's intended to be temporary storage. You could try the usual disk imaging tools (dd or partimage) but I'm not sure that's what you want. A more elegant way might be to investigate having a partition on the SD card and then using a union mount (e.g. "OverlayFS" or "aufs") to put the tmpfs over it that you can then sync to the actual SD card once in while? – Roger Jones Mar 3 '20 at 10:01
  • Does exists "unmount" and then "mount" again for tmpfs mounted in fstab? This would maybe be a solution. – JanezKranjski Mar 3 '20 at 10:32
2

To backup all data from the temp directory just create a daily cron job with a tar backup job. For example this tar would do it, assuming it is executed as root:

rpi ~# /bin/tar -czf /backupdir/backup-from-tmpdir.tar.gz -V "daily backup from tmpfs" -C /tmpdir/ ./
2
  • Would dd work also? – Seamus Mar 5 '20 at 21:39
  • 1
    @Seamus I have just no idea. With dd you need a device file, something like /dev/tmpfs but that doesn't exist. Just the same with /proc and other virtual file systems. Maybe there is a way to use a loop device? – Ingo Mar 5 '20 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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