Skip to content

A robust and automated data backup solution meticulously crafted for seamless integration into your digital ecosystem.

License

Notifications You must be signed in to change notification settings

ajayagrawalgit/SafeSync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

safesync

SafeSync License SafeSync Forks SafeSync Stars SafeSync Issues SafeSync Pull Requests SafeSync Repo Size

SafeSync is a robust and versatile backup script meticulously engineered to synchronize files and directories seamlessly between user-specified source and destination paths within the filesystem. Offering unparalleled flexibility, this tool ensures a user-friendly experience with its configuration driven by the config.json file. Users can effortlessly tailor their backup strategy by adjusting parameters such as backup intervals, exception files, and more. SafeSync's strength lies in its ability to provide comprehensive logging and exception handling, ensuring a reliable and efficient backup process. Specially designed not only for personal machines but also for professional-grade servers, SafeSync is the go-to tool for users seeking a dependable and customizable backup solution. Whether you are a casual user in need of a straightforward backup or a power user seeking a seamless and automated approach to data synchronization, SafeSync stands as the ultimate choice. Experience the convenience of file synchronization with SafeSync—your comprehensive solution for a seamless and personalized backup strategy.

Key Features:

  1. Flexibility:

    • SafeSync offers flexibility in defining source and destination paths, enabling users to tailor their backup configurations according to their specific needs.
  2. User-Friendly Configuration:

    • The tool utilizes a straightforward config.json file for configuration, making it easy for users to customize settings such as backup intervals, exception files, and more.
  3. Logging and Exception Handling:

    • SafeSync includes detailed logging functionality, recording both general logs and rsync operation details. It also provides the option to exclude specific file types during synchronization.
  4. Automated Synchronization:

    • With the ability to schedule backups at defined intervals, SafeSync automates the synchronization process, ensuring regular updates and minimizing the risk of data loss.
  5. Comprehensive Documentation:

    • The project comes with a detailed README.md file, guiding users through the installation process, configuration steps, and providing insights into the directory structure and file descriptions.

Use Cases:

  • Regular Data Backups:

    • SafeSync is ideal for users who need a simple and efficient way to perform regular backups of their important files and directories.
  • Customized Backup Strategies:

    • Users with specific requirements for backup intervals, file exclusions, and directory creation preferences can easily customize SafeSync to suit their needs.
  • Automated Synchronization:

    • SafeSync's automated synchronization feature is beneficial for users who want a hands-free approach to keeping their data up-to-date.

Why SafeSync?

SafeSync stands out as a reliable and user-friendly solution for users seeking a backup tool with flexibility, automation, and detailed logging capabilities. Whether you're a casual user looking for an easy way to safeguard your files or a power user with specific backup requirements for your servers, SafeSync provides a versatile and efficient solution.


Directory Structure and File Details

└── SafeSync
    ├── LICENSE
    ├── README.md
    ├── config
    │   ├── backup_list.txt
    │   └── config.json
    ├── logs
    │   ├── rsync.log
    │   └── safesync.log
    ├── safesync.sh
    └── src
        ├── essentials.sh
        └── load_json_config.py

File Descriptions

  1. LICENSE: Contains the licensing information for the SafeSync tool.

  2. README.md: The primary documentation file providing detailed information about the SafeSync tool, its configuration, and usage.

  3. config:

    • backup_list.txt: A crucial file specifying the source and destination paths for synchronization.
    • config.json: Configuration file containing various settings for SafeSync, such as backup interval, exceptions, and more.
  4. logs:

    • rsync.log: Log file recording details of the rsync operation.
    • safesync.log: Log file capturing general logs from the SafeSync tool.
  5. safesync.sh: The main script file responsible for executing the SafeSync tool.

  6. src:

    • essentials.sh: Script file containing essential functions and utilities used by SafeSync.
    • load_json_config.py: A Python script for loading and processing the configuration from config.json.

Locating Configuration Files

To find the exact path of the files needed for configuration (backup_list.txt and config.json), navigate to the SafeSync directory and access the config subdirectory. The configuration files are located there:

cd SafeSync/config

Now, you can view or modify the contents of backup_list.txt and config.json for customizing the SafeSync tool according to your preferences.

Locating Log Files

If you need to access the log files generated by the SafeSync tool, follow the steps below to find the exact path to the log files:

  1. rsync.log:

    • The rsync.log file records details of the rsync operation.
    • The path to rsync.log is relative to the SafeSync directory.
    • To access rsync.log, navigate to the logs subdirectory:
      cd SafeSync/logs
      You can then view or analyze the contents of rsync.log using your preferred text editor or viewer.
  2. safesync.log:

    • The safesync.log file captures general logs from the SafeSync tool.
    • Similar to rsync.log, the path to safesync.log is relative to the SafeSync directory.
    • To access safesync.log, navigate to the logs subdirectory:
      cd SafeSync/logs
      Open safesync.log using your preferred text editor or viewer to review the tool's general logs.

By following these steps, you can easily locate and access the log files generated by SafeSync for monitoring and troubleshooting purposes.



Installation and Execution Guide

Prerequisites

  1. Bash Shell Environment: Ensure that your system has a Bash shell. You can check this by running:

    echo $SHELL

    If the output is /bin/bash or similar, you have a Bash shell.

  2. Python 3: SafeSync is tested on Python 3. So, if you don't have any constraints about maintaining a certain python version in your machine, you can choose to install Python3 using any method listed below. Otherwise, SafeSync should potentially work on any version of python.

    • On Debian/Ubuntu:

      sudo apt-get install python3
    • On Red Hat/Fedora:

      sudo dnf install python3
    • On macOS:

      brew install python3
    • On Windows: Download and install Python 3 from the official Python website.

  3. jq (JSON Processor) - OPTIONAL: SafeSync uses jq for JSON parsing. Install it using your package manager.

    • On Debian/Ubuntu:

      sudo apt-get install jq
    • On Red Hat/Fedora:

      sudo dnf install jq
    • On macOS:

      brew install jq
    • On Windows: Download and install jq from the official jq website.


Installation Steps

  1. Clone the Repository: Clone the SafeSync repository to your local machine.

    git clone https://github.com/ajayagrawalgit/SafeSync.git

  1. Navigate to the SafeSync Directory: Change to the SafeSync directory.

    cd SafeSync

  1. Configure config.json: Edit the config/config.json file to customize SafeSync for your requirements. Refer to the provided config.json template for guidance.

    {
        "backup_interval": 10,
        "backup_list": "/path/to/backup_list.txt",
        "exceptions": [".xml", ".html", ".yaml"],
        "create_dirs": "true",
        "log_destination": "/path/to/logs/safesync.log",
        "rsync_log": "/path/to/logs/rsync.log",
        "python_command": "python3",
        "secure_backup_interval": 3600
    }
    • backup_interval: The interval, in seconds, at which SafeSync will execute. Adjust this value to determine how frequently the backup process runs.

    • backup_list: Specify the location where backup_list.txt is stored. Provide the full path after cloning or downloading the repository.

    • exceptions: Specify file extensions to exclude during synchronization. Modify the existing list as needed, adhering to the current format.

    • create_dirs: Set this to "true" to instruct SafeSync to create parent directories in the destination path mirroring the source structure. Use "false" if you only want to copy files within the existing destination without creating parent directories.

    • log_destination: Specify the location where safesync.log is stored. Provide the full path after cloning or downloading the repository.

    • rsync_log: Define the location for the rsync.log file. Provide the full path after cloning or downloading the repository.

    • python_command: Enter the command used to run Python scripts on your machine. Typically, this is either python or python3. Ensure accurate representation based on your system configuration.

    • secure_backup_interval: This variable should be entered in seconds which specifies that if the source file is changed within this time since the script has started running, SafeSync will rename the same file in the destination path as backup and copy the fresh file with the original name to the destination. By default, it's 3600 seconds i.e. 1 hour.


  1. Configure backup_list.txt:

    This file dictates the source and destination paths engaged in the synchronization process. Follow the specified format when inputting paths:

    /complete/path/to/Source/directory_1   /complete/path/where_you_want_to_backup_directory_1/ie_destination_1
    /complete/path/to/Source/directory_2   /complete/path/where_you_want_to_backup_directory_1/ie_destination_2
    /complete/path/to/Source/directory_3   /complete/path/where_you_want_to_backup_directory_1/ie_destination_3
    • Paths are separated by a tab.
    • The initial segment represents the source, housing the original files and folders.
    • The subsequent column, situated directly in front of the source path, designates the destination where the backup of the respective source will be stored.

  1. Run SafeSync: Execute the SafeSync script to initiate the backup process.

    ./safesync.sh

    This script reads the config.json file, performs backup tasks, and logs results.


  1. Monitor Log Files: Check the log files (safesync.log and rsync.log) for detailed information about the backup process, success, or failure.


Important Notes

  • Backup List File (backup_list.txt): The backup_list.txt file should contain pairs of source and destination paths, separated by spaces, each pair on a new line.

     /complete/path/to/Source/directory_1   /complete/path/where_you_want_to_backup_directory_1/ie_destination_1
     /complete/path/to/Source/directory_2   /complete/path/where_you_want_to_backup_directory_1/ie_destination_2
     /complete/path/to/Source/directory_3   /complete/path/where_you_want_to_backup_directory_1/ie_destination_3
  • Exception Handling: SafeSync excludes files with extensions specified in the exceptions array during the backup process. If you don't need any exceptions at all, just leave a blank array like []

  • Directory Creation: The create_dirs flag determines whether SafeSync should create destination directories.

  • Logging: Log files (safesync.log and rsync.log) store detailed information about the backup process, including success and failure messages. So make sure you provide correct path for these logs.


Contributions and Issues

Feel free to contribute to SafeSync by submitting issues or pull requests here.

License

This project is licensed under the MIT License.



🧑🏻 Know Me More

Developer - Ajay Agrawal


🤝 Support Me 🤝

Buy me a Coffee




Made with ♥️ in India


About

A robust and automated data backup solution meticulously crafted for seamless integration into your digital ecosystem.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published