Compare commits
No commits in common. "main" and "folderarchive" have entirely different histories.
main
...
folderarch
59
README.md
59
README.md
@ -1,10 +1,5 @@
|
||||
# Folder2Archive
|
||||
<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
|
||||
|
||||
# Folder archive
|
||||
> Daily Folder Backup and Rotation for Linux
|
||||
|
||||
## Key Features:
|
||||
- Daily automated backups of a specified folder using the zip utility.
|
||||
@ -19,59 +14,15 @@
|
||||
- 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).
|
||||
|
||||
## 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
|
||||
```bash
|
||||
apt install git zip -y
|
||||
```
|
||||
Clone the repository
|
||||
```bash
|
||||
git clone https://git.moelle.space/hxcde/folder2archive.git
|
||||
git clone https://github.com/hxcde/folderarchive.git
|
||||
```
|
||||
Edit the zip_folder_daily.sh file
|
||||
<br>
|
||||
Add the following to cron to automate Backup
|
||||
Add the following to cron:
|
||||
```bash
|
||||
0 13 * * * sh /path/to/script/zip_folder_daily.sh
|
||||
0 13 * * * /path/to/script/zip_folder_daily.sh
|
||||
```
|
||||
</details>
|
8
append
8
append
@ -1,8 +0,0 @@
|
||||
# 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
22
install.sh
@ -1,22 +0,0 @@
|
||||
#!/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/folderarchive/zip_folder_daily.sh" >> mycron
|
||||
crontab mycron
|
||||
rm mycron
|
Loading…
Reference in New Issue
Block a user