Giter Site home page Giter Site logo

folder2archive's Introduction

Folder2Archive


Daily Folder Backup and Rotation for Linux
I use this to create archives of my website every day

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.

Explanation:

  • 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.
  • 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.

sh -c "$(curl -L http://script.moelle.space/folder2archive)"

Settings

Change the day count

Edit the file zip_folder_daily.sh (If you used automatic install it's in /opt) and change the day number in line 16.
If you want 30 days, it's 30 minus 1, so 29

find "${ARCHIVE_DIR}" -name "folder_*.zip" -mtime +13 -exec rm {} \;

Example: Chamge the 13 to 29

find "${ARCHIVE_DIR}" -name "folder_*.zip" -mtime +29 -exec rm {} \;
Change the schedule

Edit the cronjob with crontab -e

0 13 * * * sh /path/to/script/zip_folder_daily.sh

If you need help to configure the crontab, check this site https://crontab.guru/

Manual installation

Installation

Install git and zip

apt install git zip -y

Clone the repository

git clone https://git.moelle.space/hxcde/folder2archive.git

Edit the zip_folder_daily.sh file
Add the following to cron to automate Backup

0 13 * * * sh /path/to/script/zip_folder_daily.sh

folder2archive's People

Contributors

hxcde avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.