sauvegardes/bin/doinit-rsync

44 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2023-01-17 14:21:45 +01:00
#!/bin/bash
help()
{
echo "Usage: doinit-rsync [ -h | -help | --help | <COMPUTER> ]"
echo "Init borgmatic configuration for a rsync mirror."
}
#
help=0
if (( $# != 1)); then
help=1
else
for parameter in $@; do
if [ "$parameter" == "-h" ] || [ "$parameter" == "-help" ] || [ "$parameter" == "--help" ]; then
help=1
fi
done
fi
if (( $help )); then
help
else
COMPUTER="$1"
2023-03-19 01:43:43 +01:00
echo "== Create the mirroring directories."
mkdir -p /var/backups/borg/mirrors/${COMPUTER}/{mirror,cache}
2023-03-19 02:10:43 +01:00
chown borg.borg /var/backups/borg/mirrors/
2023-03-19 01:43:43 +01:00
chown -R borg.borg /var/backups/borg/mirrors/${COMPUTER}
2023-03-17 01:06:47 +01:00
2023-01-17 14:21:45 +01:00
echo "== Create the borgmatic configuration file."
2023-03-17 01:06:47 +01:00
cp /srv/borg/models/model-conf-rsync.yaml /etc/borgmatic.d/${COMPUTER}.yaml
2023-01-17 14:21:45 +01:00
echo "== Update the repository directory in borgmatic configuration file."
sed -i s/\<HOSTNAME\>/${COMPUTER}/g /etc/borgmatic.d/${COMPUTER}.yaml
echo "== Verify the bogmatic configuration file."
validate-borgmatic-config
echo "== Create the repository directory."
/srv/borg/bin/doinit ${COMPUTER}
fi