Compare commits
28 Commits
folderarch
...
folderarch
Author | SHA1 | Date | |
---|---|---|---|
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 |
23
README.md
23
README.md
@ -14,15 +14,30 @@
|
||||
- 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/folderarchive)"
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Manual installation
|
||||
<details>
|
||||
<summary>expand </summary>
|
||||
<br>
|
||||
|
||||
Install git and zip
|
||||
```bash
|
||||
apt install git zip -y
|
||||
```
|
||||
Clone the repository
|
||||
```bash
|
||||
git clone https://github.com/hxcde/folderarchive.git
|
||||
git clone https://git.moelle.space/hxcde/folderarchive.git
|
||||
```
|
||||
Add the following to cron:
|
||||
Add the following to cron to automate Backup
|
||||
```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/folderarchive/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
|
Reference in New Issue
Block a user