Create service to select the 200 most recently synchronized HTTP or HTTPS mirrors, sort them by download speed, and overwrite the file /etc/pacman.d/mirrorlist.
# msmtp system wide configuration file
# A system wide configuration file with default account.
defaults
# The SMTP smarthost.
host smtp.fastmail.com
port 465
# Construct envelope-from addresses of the form "user@oursite.example".
#auto_from on
maildomain <your domain>
# Use TLS.
tls on
tls_starttls off
# Activate server certificate verification
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER.
syslog LOG_MAIL
aliases /etc/aliases
# msmtp root account, inherit from 'default' account
account default
user <your email>
from system@<your domain>
# Terrible...
# auth plain
# password <pass>
# or with passwordeval,
# passwordeval "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.msmtp-root.gpg"
account root : default
# password, see below
Set permissions.
chmod 600 /etc/msmtprc
Add aliases to /etc/aliases.
root: root@<yourdomain>
Create an ssmtp group and set the owner of /etc/msmtp and the msmtp binary.
Set all datasets to snapshot and disable any datasets that dont require snapshotting.
for ds in $(zfs list -H -o name); do
MP="$(zfs get -H -o value mountpoint $ds )";
if [ ${MP} == "legacy" ] || [ "${MP}" == "/" ]; then
echo "${ds}: on";
zfs set com.sun:auto-snapshot=true ${ds};
else
echo "${ds}: off";
zfs set com.sun:auto-snapshot=false ${ds};
fi;
done
In one line:
for ds in $(zfs list -H -o name); do MP="$(zfs get -H -o value mountpoint $ds )"; if [ ${MP} == "legacy" ] || [ "${MP}" == "/" ]; then echo "${ds}: on"; zfs set com.sun:auto-snapshot=true ${ds}; else echo "${ds}: off";zfs set com.sun:auto-snapshot=false ${ds}; fi; done
Create a config for each dataset thet needs replicating, where SYSTEM will be a name for the dataset at ${POOL}/replication/${SYSTEM} on the remote. Specify the remote user and IP as well. Here is a small script I use for my setup. The grep can be adjusted to exclude any datasets that are unwanted.
#!/bin/sh
REMOTE_POOL_ROOT="${1}"
REMOTE_USER="${2}"
REMOTE_IP="${3}"
for ds in $(zfs list -H -o name | \
grep -E 'data/|default|john|usr/|var/|lib/' | \
grep -v cache); do
echo "Creating: ${REMOTE_USER}@${REMOTE_IP}:${REMOTE_POOL_ROOT}/${ds}"
# See ssh(1) for -tt
# https://www.freebsd.org/cgi/man.cgi?query=ssh
# In simple terms, force pseudo-terminal and pseudo tty
ssh -tt ${REMOTE_USER}@${REMOTE_IP} \
"~/znap_check_dataset ${REMOTE_POOL_ROOT}/${ds}"
znapzendzetup create --tsformat='%Y-%m-%d-%H%M%S' \
SRC '1d=>15min,7d=>1h,30d=>4h,90d=>1d' ${ds} \
DST:${REMOTE_IP} '1d=>15min,7d=>1h,30d=>4h,90d=>1d,1y=>1w,10y=>1month' \
"${REMOTE_USER}@${REMOTE_IP}:${REMOTE_POOL_ROOT}/${ds}"
done
On remote I have a pre-znazendzetup script which makes sure the remote location exists.
#!/bin/sh
# Pre zapzendzetup script. Put in ~/znap_check_dataset on remote and run with
ds="${1}"
if [ "$(zfs list -H -o name "${ds}")" = "${ds}" ]; then
echo "${ds} exists, running ZnapZend."
else
echo "Creating non-existant dataset ${ds}"
zfs create -p "${ds}"
zfs unmount "${ds}"
echo "${ds} created, running ZnapZend."
fi
I would then run, for chin on replicator@<server ip>.
Long or short tests can be run on a disk. A short test will check for device problems. The long test is just a short test plus complete disc surface examination.
Long test example:
smartctl -t long /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_152271401093
smartctl -t long /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_154501401266
smartctl -t long /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_164277402487
smartctl -t long /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_164277402657
smartctl -t long /dev/disk/by-id/ata-Samsung_SSD_840_EVO_250GB_S1DBNSADA75563M
smartctl -a /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_152271401093
smartctl -a /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_154501401266
smartctl -a /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_164277402487
smartctl -a /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_164277402657
smartctl -a /dev/disk/by-id/ata-Samsung_SSD_840_EVO_250GB_S1DBNSADA75563M
Daemon
The smartd daemon can also run, periodically running tests and will send you a message if a problem occurs.
Edit the configuration file at /etc/smartd.conf.
nano /etc/smartd.conf
To check for all errors on a disk use the option -a after the disk ID.
/dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_152271401093 -a -m <email>
/dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_154501401266 -a -m <email>
/dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_164277402487 -a -m <email>
/dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_164277402657 -a -m <email>
/dev/disk/by-id/ata-Samsung_SSD_840_EVO_250GB_S1DBNSADA75563M -a -m <email>
To test if your mail notification is working run a test, add -m <email address> -M test to the end of the config. This will run the test on the start of the daemon.:
DEVICESCAN -m <email address> -M test
Start smartd:
systemctl start smartd
My config looks like:
/dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_152271401093 -a -m <email>
/dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_154501401266 -a -m <email>
/dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_164277402487 -a -m <email>
/dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_164277402657 -a -m <email>
/dev/disk/by-id/ata-Samsung_SSD_840_EVO_250GB_S1DBNSADA75563M -a -m <email>