2021-10-21 21:40:47 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
TYPE='' # usb / sshfs
|
|
|
|
CMD=rsync
|
|
|
|
ARGS='-avz --delete
|
|
|
|
--exclude /Nextcloud
|
|
|
|
--exclude /.cache
|
|
|
|
--exclude /Downloads
|
|
|
|
--exclude /.thunderbird
|
|
|
|
--exclude /Projects
|
|
|
|
--exclude /Software
|
|
|
|
--exclude /tmp
|
|
|
|
--exclude /fonts
|
|
|
|
--exclude /Music
|
|
|
|
--exclude /node_modules
|
|
|
|
--exclude /snap
|
|
|
|
--exclude /.local/share/Trash
|
|
|
|
--exclude /.npm
|
|
|
|
--exclude /.thumbnails
|
|
|
|
--exclude /Android
|
|
|
|
--exclude /.AndroidStudio*
|
|
|
|
--exclude /.android
|
|
|
|
--exclude /.bundle/cache
|
|
|
|
--exclude /.config/cache
|
|
|
|
--exclude /.config/Code/Cache
|
|
|
|
--exclude /.config/Code/CachedData
|
|
|
|
--exclude /.config/Slack
|
|
|
|
--exclude /.config/*/Cache
|
|
|
|
--exclude /.config/chromium
|
|
|
|
--exclude /.mozilla
|
|
|
|
--exclude /.config/discord
|
|
|
|
--exclude /.config/spotify
|
|
|
|
--exclude /.crashlytics
|
|
|
|
--exclude /.fastlane
|
|
|
|
--exclude /.gradle
|
|
|
|
--exclude ./Software
|
|
|
|
--exclude /.local
|
2022-01-25 13:24:57 +01:00
|
|
|
--exclude /.DataGrip*
|
|
|
|
--exclude /OneDrive'
|
2021-10-21 21:40:47 +02:00
|
|
|
ORIG='/home/dbroqua/'
|
|
|
|
DEST=''
|
|
|
|
HOSTNAME=`hostname`
|
|
|
|
|
|
|
|
|
|
|
|
# USB
|
|
|
|
UUID='6e3f7ae3-8fa1-43f3-88c0-a12651519ffb'
|
|
|
|
MOUNT='/mnt/backup'
|
|
|
|
DEST_USB="/mnt/backup/${HOSTNAME}/dbroqua/"
|
|
|
|
# SSHFS
|
2022-01-25 13:24:57 +01:00
|
|
|
DEST_SSHFS="dmc-12:Backup/${HOSTNAME}/dbroqua/"
|
2021-10-21 21:40:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
while getopts t:h opt
|
|
|
|
do
|
|
|
|
case $opt in
|
|
|
|
t)
|
|
|
|
case ${OPTARG} in
|
|
|
|
usb)
|
|
|
|
TYPE='usb'
|
|
|
|
DEST=${DEST_USB}
|
|
|
|
;;
|
|
|
|
sshfs)
|
|
|
|
TYPE='sshfs'
|
|
|
|
DEST=${DEST_SSHFS}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "usb / sshfs attendu"
|
|
|
|
exit 1;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${TYPE}" != '' ] ; then
|
|
|
|
case ${TYPE} in
|
|
|
|
usb)
|
|
|
|
sudo cryptsetup luksOpen /dev/sdb1 backup
|
|
|
|
sudo mount /dev/mapper/backup ${MOUNT}
|
|
|
|
echo "Go !"
|
|
|
|
if [ $? == 0 ] ; then
|
|
|
|
${CMD} ${ARGS} ${ORIG} ${DEST}
|
|
|
|
fi
|
|
|
|
sudo umount ${MOUNT}
|
|
|
|
sudo cryptsetup luksClose backup
|
|
|
|
;;
|
|
|
|
sshfs)
|
|
|
|
${CMD} ${ARGS} ${ORIG} ${DEST}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $? == 0 ] ; then
|
2022-01-25 13:24:57 +01:00
|
|
|
echo `date` > ${ORIG}lastBackup
|
2021-10-21 21:40:47 +02:00
|
|
|
echo "Method: ${TYPE}" >> ${ORIG}/lastBackup
|
2022-01-25 13:24:57 +01:00
|
|
|
rm ${ORIG}lastFailBackup
|
2021-10-21 21:40:47 +02:00
|
|
|
else
|
2022-01-25 13:24:57 +01:00
|
|
|
echo `date` > ${ORIG}lastFailBackup
|
|
|
|
echo "Method: ${TYPE}" >> ${ORIG}lastFailBackup
|
2021-10-21 21:40:47 +02:00
|
|
|
fi
|
|
|
|
|