Skip to content

djharshit/backup-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Automated Backup and Rotation Script

Overview

This script automates the backup process for a project's code files, implements a rotational backup strategy, and integrates with Google Drive to push the backups to a specified folder. Additionally, it deletes older backups according to the rotational strategy and sends a webhook notification on successful backup.

Requirements

  • Python 3.x
  • Google API Python Client
  • Google Auth
  • Requests

Installation

  1. Clone the repository:
git clone https://github.com/djharshit/backup-script
cd backup-script
  1. Install the required Python packages:
pip3 install -r requirements.txt
  1. Set up your environment variables in a .env file:
PROJECT_PATH=/path/to/your/project
GDRIVE_FOLDER_ID=your_google_drive_folder_id
RETENTION=retention_number
USE_WEBHOOK=True
WEBHOOK_URL=your_webhook_url

Configuration

  1. Google Drive Integration:
  • Ensure you have a credentials.json file for Google Drive API authentication. Place the file in the root directory of the project.
  1. Environment Variables:
  • PROJECT_PATH: Path to the project folder you want to back up.
  • GDRIVE_FOLDER_ID: Google Drive folder ID where backups will be uploaded.
  • RETENTION: Number of days to retain backups.
  • WEBHOOK_URL: URL to send a webhook notification on successful backup.
  • USE_WEBHOOK: Set to True to enable webhook notifications.

Usage

Run the script:

python3 one.py

Logging

The script logs all activities to logs.log file, including backup creation, upload status, and cleanup of old backups.

Cleanup Old Backups

The script deletes old backups from the backups directory based on the retention period specified in the environment variables.

About

Script automation of backup process

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages