script update
This commit is contained in:
@@ -53,6 +53,11 @@
|
||||
- name: Install Restic and setup
|
||||
include: ../lib/setup-restic.yml
|
||||
|
||||
- name: Setup Restic Cron jobs
|
||||
include: ../lib/setup-restic-cron.yml
|
||||
|
||||
-
|
||||
|
||||
- name: Write docker-compose.yml
|
||||
ansible.builtin.copy:
|
||||
content: "{{ docker_compose_definition }}"
|
||||
|
||||
@@ -31,6 +31,14 @@
|
||||
group: users
|
||||
mode: '0600'
|
||||
|
||||
- name: Copy Restic Repo Pass
|
||||
copy:
|
||||
dest: /home/restic/.resticpassword
|
||||
content: "{{ restic_repopass}}"
|
||||
owner: restic
|
||||
group: users
|
||||
mode: '0600'
|
||||
|
||||
- name: Copy restic.sh
|
||||
copy:
|
||||
dest: /home/restic/restic.sh
|
||||
@@ -96,8 +104,8 @@
|
||||
if $backup; then
|
||||
echo "Backing up... to misamisa"
|
||||
echo "Date: $(date '+%Y-%m-%d_%H-%M-%S')" # Add your Restic backup command here
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname)/$backup backup $backupdir
|
||||
if [ $? -eq 0 ]; then
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname) backup $backupdir
|
||||
if [ $? -eq 0 ] || [ $? -eq 3 ]; then
|
||||
# If the exit status is 0 (success), send a success message
|
||||
./discord.sh "$(hostname) backup complete"
|
||||
else
|
||||
@@ -110,8 +118,8 @@
|
||||
if $forget; then
|
||||
echo "Removing old backups..."
|
||||
# Add your Restic forget command here
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname)/$backupdir forget --keep-within-daily 7d --keep-within-weekly 1m --keep-within-monthly 1y
|
||||
if [ $? -eq 0 ]; then
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname) forget --keep-within-daily 7d --keep-within-weekly 1m --keep-within-monthly 1y
|
||||
if [ $? -eq 0 ] || [ $? -eq 3 ]; then
|
||||
# If the exit status is 0 (success), send a success message
|
||||
./discord.sh "$(hostname) forget command completed successfully"
|
||||
else
|
||||
@@ -123,15 +131,15 @@
|
||||
if $check; then
|
||||
echo "Checking backups..."
|
||||
# Add your Restic check command here
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname)/$backupdir check --read-data
|
||||
if [ $? -eq 0 ]; then
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname) check --read-data
|
||||
if [ $? -eq 0 ] || [ $? -eq 3 ]; then
|
||||
# If the exit status is 0 (success), send a success message
|
||||
./discord.sh "$(hostname) Restic Verification complete"
|
||||
else
|
||||
# If the exit status is not 0 (failure), send a failure message
|
||||
./discord.sh "$(hostname) Restic Verification failed!! there is an issue"
|
||||
fi
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname)/$backupdir unlock
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname) unlock
|
||||
|
||||
fi
|
||||
|
||||
@@ -142,8 +150,8 @@
|
||||
echo "Password file empty. generating passwordwq"
|
||||
tr -dc A-Za-z0-9 </dev/urandom | head -c 25 > ./.resticpassword
|
||||
fi
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname)/$backupdir init
|
||||
if [ $? -eq 0 ]; then
|
||||
restic --password-file ./.resticpassword -r sftp:misamisa://home/restic/$(hostname) init
|
||||
if [ $? -eq 0 ] || [ $? -eq 3 ]; then
|
||||
# If the exit status is 0 (success), send a success message
|
||||
./discord.sh "$(hostname) Restic Init complete for $(hostname)"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user