Automated Backup Script for Bash Configuration and Crontab Using RClone

In the world of system administration and scripting, the ability to automate repetitive tasks is a skill highly valued. One such routine task is creating backups of important configuration files, like the `bashrc` file and `crontab` settings. In this blog post, we will explore a simple yet effective bash script that automates this process and leverages the power of RClone to securely store these backups remotely.


The Script Overview

The provided bash script is designed to perform the following tasks:

URL : https://github.com/Lalatenduswain/BackUp-User-BashRC-and-Corn-Job-With-RClone-To-Google-Drive.git

1. Check for RClone Installation:

   - The script begins by checking whether RClone is installed on the system.

   - If RClone is not found, the user is prompted to install it.


2. Display RClone Version:

   - Once RClone is confirmed to be installed, the script retrieves and displays the current version.


3. Backup Configuration Files:

   - The script then sets a date format and creates a temporary backup directory.

   - It backs up the `.bashrc` file and the user's `crontab` settings into this directory.


4. Display Backup Contents:

   - The script provides a visual confirmation by listing the contents of the temporary backup directory.


5. Check RClone Configuration:

   - It checks if the RClone configuration file exists.

   - If not found, it prompts the user to create one and add their Google token.


6. Upload to Remote Location:

   - Finally, the script uploads the contents of the temporary backup directory to a remote location using RClone.


7. Clean Up:

   - The temporary backup directory is removed to clean up after the successful backup and upload.


How to Use the Script


To utilize this script effectively, follow these steps:


1. Review and Modify RClone Destination:

   - The script uploads backups to a remote location named `bunu:/My-Local-Ubuntu-System-BashRCBackup-Cron`. Modify this destination according to your RClone setup.


2. Run the Script:

   - Save the script to a file, e.g., `my-system-corn-job.sh

   - Make it executable: `chmod +x my-system-corn-job.sh

   - Run the script: `./my-system-corn-job.sh


3. Follow Prompts:

   - If RClone is not installed, the script will prompt you for installation.

   - The script will guide you through the process, displaying version information and the backup directory's contents.


4. Verify Upload:

   - Check your remote location specified in the script to ensure that the backups were successfully uploaded.


Conclusion

This script provides a hands-free way to ensure that your important configuration files are regularly backed up and securely stored. By incorporating RClone, it allows for flexibility in choosing a remote storage solution, making it an ideal tool for those who value both automation and data integrity.