Newer
Older
casp / NetBSD8 / root / sync_with_hdd.sh
@HIROSE Yuuji HIROSE Yuuji on 17 Sep 2019 716 bytes Required files located
#!/bin/sh
PATH=/usr/local/bin:$PATH

getwedge() {
  # $1=disk, $2=name, Return: device
  # eg: getwedge wd0 root   ->   /dev/dk2
  dev=`dkctl $1 listwedges|awk "\\$2 ~ /$2/{print \\$1}"`
  test -n "$dev" && echo "/dev/$dev" | tr -d :
}
root=`getwedge wd0 root`
usr=`getwedge wd0 data`

if [ -n "$root" -a -n "$usr" ]; then
  test -d /mnt || mkdir /mnt
  if mount -o log $root /mnt; then
    if [ ! -d /mnt/usr ]; then
      echo Cannot find usr/ in wd0 >&2
      umount /mnt; exit 1
    fi
    if mount -o log $usr /mnt/usr; then
      HOME=/ unison /usr/home /mnt/usr/home -batch -ignore 'Name .cache' -ignore 'Name .mozilla'
      umount /mnt/usr
      echo Synching with HDD, done.
    fi
    umount /mnt
  fi
fi