Skip to content

Commit 22c5b8e

Browse files
committed
feat(remove-old): remove backup older than 5 days
1 parent 983692c commit 22c5b8e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

thunderbird-backup.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,15 @@ else
99
fi
1010

1111
TODAY=$(date '+%Y-%m-%d') # format date 2020-06-28
12-
BACKUP_FOLDER_PATH=/home/panda/Documents/Backups/ # path for the output
12+
BACKUP_FOLDER_PATH=/home/panda/Documents/Backups/Thunderbird/ # path for the output
1313
BACKUP_FILENAME=thunderbird-profile-$TODAY # name of the generated back up
1414
THUNDERBIRD_PROFILE_PATH=/home/panda/.thunderbird/panda.default-release # path to the profile to save
15-
LOCK_FILE_PATH=/home/panda/Documents/Backups/thunderbird-backup.lock # path to the temporary lock file
15+
LOCK_FILE_PATH=/home/panda/Documents/Backups/Thunderbird/thunderbird-backup.lock # path to the temporary lock file
1616
IS_THUNDERBIRD_RUNNING=0
1717
ATTEMPTS_TO_STOP_THUNDERBIRD=5
1818

1919
# -----------------------------------------------------------------------
20-
21-
# TODO Protect contre le controle + C pour fermer le script et ask un confirmation
2220
# TODO Ne pas avoir plus de 3 sauvegarde, trouver le moyen de supprimer les vieilles
23-
# TODO Faire un fichier de log
24-
# TODO Faire une copie sur un remote ou bien sur disque a mount => créer une seconde option pour avoir un second chemin de back up sur un disque de save.
25-
# TODO Faire un readme
26-
2721
# -----------------------------------------------------------------------
2822

2923
# Check if the file already exists
@@ -105,7 +99,7 @@ fi
10599

106100
# -----------------------------------------------------------------------
107101

108-
# Now we can do backup, note: to disable silent mode remove below ">/dev/null" and "-q" flag
102+
# Now we can do backup, note: to disable silent mode remove below ">/dev/null"
109103

110104
echo "Thunderbird backup in progress..."
111105
pushd $THUNDERBIRD_PROFILE_PATH >/dev/null || exit
@@ -125,6 +119,12 @@ echo "The Lock file has already been removed."
125119

126120
# -----------------------------------------------------------------------
127121

122+
# Check if there is file older than one week and remove it
123+
find $BACKUP_FOLDER_PATH/* -type f -mtime +2 -exec rm -f {} \; &&
124+
echo "Oldest backup successfully removed."
125+
126+
# -----------------------------------------------------------------------
127+
128128
# Show notify message that backup is created
129129

130130
if [ -f "$BACKUP_FOLDER_PATH/$BACKUP_FILENAME.tar.gz" ]; then
@@ -136,4 +136,5 @@ else
136136
zenity --error --text "Thunderbird backup hasn't created.\nUnexpected error occurred." --width=400
137137
fi
138138
fi
139-
# -----------------------------------------------------------------------
139+
140+
# -----------------------------------------------------------------------

0 commit comments

Comments
 (0)