[OpenIndiana-discuss] OI rpool on USB flash in N40L?
Jim Klimov
jimklimov at cos.ru
Sun Jan 27 16:14:04 UTC 2013
On 2013-01-27 16:58, andy thomas wrote:
> 5. next, to preserve the state of /var and /tmp across reboots
> add this to your /etc/rc.shutdown.local script (you might need
> to create this if it doesn't exist):
>
> # Insert other shutdown procedures here
>
> tar czf /md_backups/var.tgz /var
> tar czf /md_backups/tmp.tgz /tmp
>
> echo '.'
> exit 0
I'd be more comfortable with a transactional approach - create the new
archive in a tempfile on the USB root disk, after successful completion
rename it over the old file and/or roll its name syslog-style to keep
the previous archive too. This way a sudden poweroff or a write error
won't leave you with no usable archive at all. For example:
rm -f /md_backups/*.__WRITING__
for F in var tmp; do
tar czf /md_backups/$F.tgz.__WRITING__ /$F && \
rm -f /md_backups/$F.tgz.prev && \
( [ -s /md_backups/$F.tgz ] && \
ln /md_backups/$F.tgz /md_backups/$F.tgz.prev || true ) && \
mv -f /md_backups/$F.tgz.__WRITING__ /md_backups/$F.tgz
done
This is off the top of my head, may need fixes to actually work right ;)
In particular, do verify that such "rm -f" succeeds regardless of the
file's existance, and that "mv -f" unlinks the older file before
renaming another over this name - i.e. inodes change (ls -lani).
HTH,
//Jim
More information about the OpenIndiana-discuss
mailing list