Add help and update readme
This commit is contained in:
parent
13a21c063b
commit
388fea92a7
3 changed files with 64 additions and 3 deletions
24
README.md
24
README.md
|
@ -1,3 +1,25 @@
|
||||||
# simple_backup
|
# simple_backup
|
||||||
|
|
||||||
Simple backup script to a USB device
|
## Description
|
||||||
|
|
||||||
|
Simple backup script that will do a backup with Restic into a USB disk every time the drive is connected (or any other USB device you select).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Just running the script will install the necessary files (restic, udev rule and user's systemd unit file) and run a first backup to initialize the respository.
|
||||||
|
|
||||||
|
## Monitoring
|
||||||
|
|
||||||
|
You can monitor the execution with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
journalctl -f --user -u simple_backup@*
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
The script will ask the necessary questions to create a configuration file if it can't be found. And if you want to reconfigure it run it with --reconfigure and it will ignore any existing configuration file.
|
||||||
|
|
||||||
|
## Localization
|
||||||
|
|
||||||
|
You can create your own translations in the locales folder. Provided a translation to Spanish-Spain as an example.
|
||||||
|
|
|
@ -16,3 +16,5 @@ initializing_low="inicializando el repositorio"
|
||||||
waiting="Esperando otros 3 segundos"
|
waiting="Esperando otros 3 segundos"
|
||||||
waited="He esperado por 60 segundos para que la carpeta de destino estuviera disponible sin exito. Comprueba la configuración y que la carpeta de destino existe."
|
waited="He esperado por 60 segundos para que la carpeta de destino estuviera disponible sin exito. Comprueba la configuración y que la carpeta de destino existe."
|
||||||
another_copy="Hay otra copia ejecutandose"
|
another_copy="Hay otra copia ejecutandose"
|
||||||
|
reconfigure_help="Reconfigurar la utilidad"
|
||||||
|
help="Mostrar esta ayuda"
|
||||||
|
|
|
@ -15,6 +15,13 @@ initializing_low="initializing repository"
|
||||||
waiting="Waiting another 3 seconds"
|
waiting="Waiting another 3 seconds"
|
||||||
waited="Waited for 60 seconds for the destination to be available without sucess. Check your configuration and that the destination folder exists"
|
waited="Waited for 60 seconds for the destination to be available without sucess. Check your configuration and that the destination folder exists"
|
||||||
another_copy="There is another copy running"
|
another_copy="There is another copy running"
|
||||||
|
reconfigure_help="Reconfigure the script"
|
||||||
|
help="Show this help"
|
||||||
|
function usage() {
|
||||||
|
echo "${script_name} [-r|--reconfigure] [-h|--help]"
|
||||||
|
echo " -r|--reconfigure ${reconfigure_help}"
|
||||||
|
echo " -h|--help ${help}"
|
||||||
|
}
|
||||||
function configure() {
|
function configure() {
|
||||||
zenity --info --text "${first_be_sure}"
|
zenity --info --text "${first_be_sure}"
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
|
@ -43,10 +50,40 @@ if [ -e "${script_dir}/locales/${locale}" ]; then
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "${script_dir}/locales/${locale}"
|
source "${script_dir}/locales/${locale}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
while [ ${#} -gt 0 ]
|
||||||
|
do
|
||||||
|
case "${1}" in
|
||||||
|
"-h"|"--help")
|
||||||
|
usage
|
||||||
|
shift
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
'-r'|'--reconfigure')
|
||||||
|
shift
|
||||||
|
configure
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Ignoring unknown parameter '${1}'"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ ! -r "${HOME}/.config/simple_backup.conf" ]; then
|
if [ ! -r "${HOME}/.config/simple_backup.conf" ]; then
|
||||||
configure
|
configure
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -x /usr/local/bin/restic ]; then
|
||||||
|
if [ "$(uname -i)" == 'x86_64' ]; then
|
||||||
|
arch="amd64"
|
||||||
|
elif [[ "$(uname -a)" =~ aarch64 ]]; then
|
||||||
|
arch='arm64'
|
||||||
|
fi
|
||||||
|
/usr/bin/wget -q -O - "$(/usr/bin/curl -s -L -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' https://api.github.com/repos/restic/restic/releases/latest | jq ".assets[]|select(.browser_download_url|contains(\"${arch}\"))|.browser_download_url" | sed 's/\"//g')" | bzip2 -dc > /usr/local/bin/restic
|
||||||
|
chmod +x /usr/local/bin/restic
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $(pgrep -f -c "${script_name}") -gt 1 ]; then
|
if [ $(pgrep -f -c "${script_name}") -gt 1 ]; then
|
||||||
echo "${another_copy}"
|
echo "${another_copy}"
|
||||||
exit 3
|
exit 3
|
||||||
|
@ -98,14 +135,14 @@ if [ ! -e "${destination}" ]; then
|
||||||
fi
|
fi
|
||||||
if [ ! -e "${destination}/config" ]; then
|
if [ ! -e "${destination}/config" ]; then
|
||||||
echo "${initializing} '${destination}'..."
|
echo "${initializing} '${destination}'..."
|
||||||
if ! restic init "${password_file[@]}" -r "${destination}"; then
|
if ! /usr/local/bin/restic init "${password_file[@]}" -r "${destination}"; then
|
||||||
zenity --error --text "${there_was_error} ${return_code} ${initializing_low}"
|
zenity --error --text "${there_was_error} ${return_code} ${initializing_low}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "${backing_up} '${folder}' ${to} '${destination}'..."
|
echo "${backing_up} '${folder}' ${to} '${destination}'..."
|
||||||
current_date=$(date +%Y.%m.%d_%H_%M_%S)
|
current_date=$(date +%Y.%m.%d_%H_%M_%S)
|
||||||
restic backup "${password_file[@]}" -r "${destination}" "${folder}" --json > "${HOME}/.logs/simple_backup_${current_date}.json"
|
/usr/local/bin/restic backup "${password_file[@]}" -r "${destination}" "${folder}" --json > "${HOME}/.logs/simple_backup_${current_date}.json"
|
||||||
return_code=${?}
|
return_code=${?}
|
||||||
cp "${HOME}/.logs/simple_backup_${current_date}.json" "${HOME}/.logs/simple_backup_last.json" -f
|
cp "${HOME}/.logs/simple_backup_${current_date}.json" "${HOME}/.logs/simple_backup_last.json" -f
|
||||||
if [ "${return_code}" != "0" ]; then
|
if [ "${return_code}" != "0" ]; then
|
||||||
|
|
Loading…
Reference in a new issue