Compare commits
64 Commits
folderarch
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| f01708712a | |||
| cb29181e76 | |||
| 37e0986745 | |||
| 6e11715467 | |||
| 67c7a66b51 | |||
| 356689bb76 | |||
| cc0b03e7ff | |||
| 264fc248ba | |||
| 3e44f9f2e6 | |||
| fd1fcd3530 | |||
| 50eef7658f | |||
| 676292be85 | |||
| 7e19fe7d19 | |||
| 49139fb445 | |||
| c109be46f7 | |||
| a426f1af49 | |||
| 8744a50562 | |||
| 3f3c743262 | |||
| 273994e82a | |||
| 400dd25e7d | |||
| df55cbd534 | |||
| 55ca28e9cb | |||
| b39abe8cc0 | |||
| d7b73ed6e9 | |||
| 024690be38 | |||
| 8cac2026ce | |||
| 8976ba7deb | |||
| 36761eefba | |||
| ca0ba76fae | |||
| 7ec219bb67 | |||
| 58f9712e53 | |||
| 568b7ac2f1 | |||
| 5b33466451 | |||
| 582e3f5248 | |||
| e372037040 | |||
| 823d0a6969 | |||
| b3b77ab7b5 | |||
| 728e9547ea | |||
| 146175988f | |||
| e9fa3986b3 | |||
| 7a3dc4e949 | |||
| 041206fadf | |||
| 267096c511 | |||
| cd4a7e0fb9 | |||
| 43b16e64af | |||
| 5db0b69a4c | |||
| a56c9d5185 | |||
| d776db6ea7 | |||
| 2a8b86fcd2 | |||
| e80976e0ee | |||
| 99b6ee9525 | |||
| 979dbb84f3 | |||
| 2369ed3136 | |||
| 82f7acf2cc | |||
| 42c50a8aa4 | |||
| acb433890c | |||
| 7890f96136 | |||
| 9b0eea276a | |||
| 9d76fa8516 | |||
| 10bd042270 | |||
|
|
bc243875a6 | ||
| a293eb866b | |||
|
|
cd65328f1b | ||
|
|
ea3d2b30f1 |
61
README.md
61
README.md
@@ -1,5 +1,10 @@
|
|||||||
# Folder archive
|
# Folder2Archive
|
||||||
> Daily Folder Backup and Rotation for Linux
|
<img align="right" width="150" src="https://git.moelle.space/hxcde/folder2archive/raw/branch/main/f2a.png">
|
||||||
|
<br>
|
||||||
|
|
||||||
|
> Daily Folder Backup and Rotation for Linux <br>
|
||||||
|
> I use this to create archives of my website every day
|
||||||
|
|
||||||
|
|
||||||
## Key Features:
|
## Key Features:
|
||||||
- Daily automated backups of a specified folder using the zip utility.
|
- Daily automated backups of a specified folder using the zip utility.
|
||||||
@@ -14,15 +19,59 @@
|
|||||||
- The find command is used to delete files older than 14 days in the archive directory. (edit in the script as needed)
|
- The find command is used to delete files older than 14 days in the archive directory. (edit in the script as needed)
|
||||||
- The cron entry schedules the script to run daily at 13:00 (1 PM).
|
- The cron entry schedules the script to run daily at 13:00 (1 PM).
|
||||||
|
|
||||||
|
## Automatic installation
|
||||||
|
|
||||||
|
Paste the script in your machines console.
|
||||||
|
```bash
|
||||||
|
sh -c "$(curl -L http://script.moelle.space/folder2archive)"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Change the day count </summary>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
Edit the file zip_folder_daily.sh `(If you used automatic install it's in /opt)` and change the day number in line 16.
|
||||||
|
<br> If you want 30 days, it's `30 minus 1`, so `29`
|
||||||
|
```bash
|
||||||
|
find "${ARCHIVE_DIR}" -name "folder_*.zip" -mtime +13 -exec rm {} \;
|
||||||
|
```
|
||||||
|
Example: Chamge the `13` to `29`
|
||||||
|
```bash
|
||||||
|
find "${ARCHIVE_DIR}" -name "folder_*.zip" -mtime +29 -exec rm {} \;
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Change the schedule </summary>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
Edit the cronjob with `crontab -e`
|
||||||
|
```bash
|
||||||
|
0 13 * * * sh /path/to/script/zip_folder_daily.sh
|
||||||
|
```
|
||||||
|
If you need help to configure the crontab, check this site https://crontab.guru/
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
## Manual installation
|
||||||
|
<details>
|
||||||
|
<summary>Installation </summary>
|
||||||
|
<br>
|
||||||
|
|
||||||
Install git and zip
|
Install git and zip
|
||||||
```bash
|
```bash
|
||||||
apt install git zip -y
|
apt install git zip -y
|
||||||
```
|
```
|
||||||
Clone the repository
|
Clone the repository
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/hxcde/folderarchive.git
|
git clone https://git.moelle.space/hxcde/folder2archive.git
|
||||||
```
|
```
|
||||||
Add the following to cron:
|
Edit the zip_folder_daily.sh file
|
||||||
|
<br>
|
||||||
|
Add the following to cron to automate Backup
|
||||||
```bash
|
```bash
|
||||||
0 13 * * * /path/to/script/zip_folder_daily.sh
|
0 13 * * * sh /path/to/script/zip_folder_daily.sh
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
8
append
Normal file
8
append
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Create a timestamp in the format YYYY-MM-DD
|
||||||
|
DATE=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
|
# Create the zipped archive and append the date
|
||||||
|
zip -r "${ARCHIVE_DIR}/folder_${DATE}.zip" "${SOURCE_DIR}"
|
||||||
|
|
||||||
|
# Delete files older than 14 days
|
||||||
|
find "${ARCHIVE_DIR}" -name "folder_*.zip" -mtime +13 -exec rm {} \;
|
||||||
22
install.sh
Normal file
22
install.sh
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo checking if Zip is installed
|
||||||
|
apt-get install zip -y
|
||||||
|
#yum install zip -y
|
||||||
|
#apk add zip
|
||||||
|
cd /opt/
|
||||||
|
echo "#!/bin/bash" > zip_folder_daily.sh
|
||||||
|
echo "#Enter the directory to be zipped (e.g., /path/to/folder)" >> zip_folder_daily.sh
|
||||||
|
echo "Enter the directory to be zipped (e.g., /path/to/folder)"
|
||||||
|
read path
|
||||||
|
echo "SOURCE_DIR='"$path"'" >> zip_folder_daily.sh
|
||||||
|
echo "# Enter the directory where the zipped files will be stored (e.g., /path/to/archive)" >> zip_folder_daily.sh
|
||||||
|
echo "Enter the directory where the zipped files will be stored (e.g., /path/to/archive)"
|
||||||
|
read archive
|
||||||
|
echo "ARCHIVE_DIR='"$archive"'" >> zip_folder_daily.sh
|
||||||
|
curl https://git.moelle.space/hxcde/folder2archive/raw/branch/main/append >> zip_folder_daily.sh
|
||||||
|
sh /opt/zip_folder_daily.sh
|
||||||
|
|
||||||
|
crontab -l > mycron
|
||||||
|
echo "0 13 * * * sh /opt/zip_folder_daily.sh" >> mycron
|
||||||
|
crontab mycron
|
||||||
|
rm mycron
|
||||||
Reference in New Issue
Block a user