Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jul 2002 20:40:35 -0400
From:      "ro0t" <root@unixhideout.com>
To:        <freebsd-questions@freebsd.org>
Subject:   RE: How does /etc/daily.local run.
Message-ID:  <CGEIKJFNGMJHCMFBJGJFEEHHCAAA.root@unixhideout.com>
In-Reply-To: <200207020221.57680.danny@ricin.com>

next in thread | previous in thread | raw e-mail | index | archive | help
God how i love FreeBSD. And this list. I am always learning new stuff.
Thanks to all of ya!

-----Original Message-----
From: Danny Pansters [mailto:danny@ricin.com]
Sent: Monday, July 01, 2002 8:22 PM
To: ro0t
Subject: Re: How does /etc/daily.local run.


On Tuesday 02 July 2002 01:16, ro0t wrote:
> this. In /etc/daily.local there are several commands, does my mighty bsd
> box run them all at the same time, or does it wait until each is finished
> and start the next job?

They run one after the other, hence the numbers in the names of the daily,
weekly, monthly scripts under /etc/periodic. Works like the start|stop
scripts in /usr/local/etc/rc.d somewhat as they are run alphabetically.

You can add your own, e.g. 900.do_my_thing or stick your stuff in the
999.local, or use a /usr/local/etc/periodic. All are possible and supported.
You can define variables like RUN_MY_STUFF="YES" or so by doing some copying
and pasting from another periodic script that comes close to what you need
and then change it to have the functionality you want. Those variables can
be
used in /etc/periodic.conf (or a local version thereof), just like the
"predefined" onces that come with the default base OS.

HTH,

--Dan



PS,

An example says more than a thousand words. Here's a simple but effective
example that I use to backup my root partition to a spare one on a second
disk (other partitions are mirrored between the two disks using vinum) so
that in case the first disk would crash I can boot from the second disk
instead. The zip compression step could be left out but is included to be
able to copy the dumped data offsite from this script if I want to later.

----------------- daily script thingie ---------------------
# cat /etc/periodic/daily/900.backup-root
#!/bin/sh
#
# /etc/periodic/daily/900.backup_root
#

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

case "$backup_root_enable" in
    [Yy][Ee][Ss])
        #
        # This should only be run if there are two functioning disks and it
        # should NOT be run on disk1, disk0 = da1s0a and disk1 = da1s1a
        #
        echo ""
        echo "Backing up root partition /dev/da0a to /dev/da1a. "
            mount /dev/da1s1a /backup_root
            cd /backup_root
            chflags -R noschg *
            case "$backup_root_compress" in
                [Yy][Ee][Ss])
                    echo "Remove old backup files."
                    rm -rf /backup_root/*
                    echo -n "Performing dump of root filesystem"
                    case "$backup_root_compress_bzip2" in
                        [Yy][Ee][Ss])
                            echo " with bzip2 compresion."
                            /sbin/dump -0uan -f - / | bzip2 -2 >
root.dump.bz2
                            echo "Unzipping."
                            bunzip2 root.dump.bz2
                            ;;
                        *)
                            echo " with gzip compresion."
                            /sbin/dump -0uan -f - / | gzip -2 > root.dump.gz
                            echo "Unzipping."
                            gunzip root.dump.gz
                            ;;
                    esac
                    ;;
                *)
                    /sbin/dump -0uan -f - / > root.dump
                    echo "."
                    ;;
            esac
            echo "Restoring today's backup root filesystem. "
            case "$backup_root_replace" in
                [Yy][Ee][Ss])
                    restore -rf root.dump
                    ;;
                *)
                    echo "Replacement of backup root filesystem not enabled!
"
                    ;;
            esac
            cd /
            umount /backup_root
            ;;
        *)
        echo "Are you sure you don't want to backup your root partition?"
esac
echo "Done."
exit 0
---------------------- end -----------------------------

----- addition to periodic.conf (in 'daily' part) ------
# 900.backup_root
backup_root_enable="YES"	# root partition backup
backup_root_compress="YES"
backup_root_compress_bzip2="YES"
backup_root_replace="YES"
------------------------ end ---------------------------


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CGEIKJFNGMJHCMFBJGJFEEHHCAAA.root>