sauvegardes/Plan Borg/bin/doinit-rsync

45 lines
1.1 KiB
Plaintext
Raw 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-17 01:06:47 +01:00
echo "== Create the mirroring directory."
2023-03-17 17:07:47 +01:00
mkdir -p /var/backups/borg/mirrors/${COMPUTER}
2023-03-17 01:06:47 +01:00
echo "== Create dedicated cache."
mkdir /var/backups/borg/mirrors/${COMPUTER}.cache
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