2023-04-08 21:47:06 +02:00
|
|
|
# Folder archive
|
2023-04-08 21:51:30 +02:00
|
|
|
> Daily Folder Backup and Rotation for Linux
|
2023-04-08 21:40:28 +02:00
|
|
|
|
2023-04-08 21:42:38 +02:00
|
|
|
## Key Features:
|
|
|
|
- Daily automated backups of a specified folder using the zip utility.
|
|
|
|
- Date-appended archive file names for easy identification.
|
|
|
|
- Automatic removal of backups older than 14 days.
|
|
|
|
- Scheduled execution using cron for a hands-off approach.
|
|
|
|
|
2023-04-08 21:40:28 +02:00
|
|
|
## Explanation:
|
2023-04-08 21:41:16 +02:00
|
|
|
- The script sets the source directory (SOURCE_DIR) that will be zipped and the archive directory (ARCHIVE_DIR) where the zipped files will be stored.
|
|
|
|
- It creates a timestamp in the format YYYY-MM-DD and stores it in the DATE variable.
|
|
|
|
- The zip command is used to create the zipped archive and append the date to the file name.
|
2023-04-12 01:49:43 +02:00
|
|
|
- The find command is used to delete files older than 14 days in the archive directory. (edit in the script as needed)
|
2023-04-08 21:41:16 +02:00
|
|
|
- The cron entry schedules the script to run daily at 13:00 (1 PM).
|
2023-04-08 21:44:08 +02:00
|
|
|
|
2023-04-08 21:45:44 +02:00
|
|
|
Install git and zip
|
|
|
|
```bash
|
|
|
|
apt install git zip -y
|
|
|
|
```
|
|
|
|
Clone the repository
|
|
|
|
```bash
|
2023-04-12 16:28:25 +02:00
|
|
|
git clone https://git.moelle.space/hxcde/folderarchive.git
|
2023-04-08 21:45:44 +02:00
|
|
|
```
|
2023-04-08 21:44:08 +02:00
|
|
|
Add the following to cron:
|
|
|
|
```bash
|
2023-04-12 11:43:51 +02:00
|
|
|
0 13 * * * sh /path/to/script/zip_folder_daily.sh
|
2023-04-11 23:06:57 +02:00
|
|
|
```
|