SQL Dumps and offsite backup scripts.

Discussion in 'Tips/Tricks/Mods' started by thisiszeev, Oct 5, 2023.

  1. thisiszeev

    thisiszeev Member

    Note: I hope this is in the right section, if not, please let me know and I will repost.

    Hi all, I have created two little scripts to server a task that I needed to be automated.

    I wanted a way to back up specific folders on each of my ISPConfig servers. I wanted the backups to include all my client's SQL databases, and I wanted it to be daily, with tar.gz archives of the last seven days, the last 5 weeks and the last 6 months.

    I created two scripts.

    1. SQLDumps

    I put this script in /var/sqldumps. I gave it "included on the git copy by default" the databases I don't need backed up, in the case of a ISPConfig 3.2 install. In the script file you will see an array, you can edit the list there. It is commented to indicate where to do it. I run it each day at 8pm via crontab.

    2. daily-backup

    For each of my servers, I run on a local server here at my office, a copy of the script, one folder per server, a copy in each folder. Again, I have used an array to list the folders to backup. You will see by default it contains the sqldumps location as well as vmail, mail, www etc. I set it run 4 times a day for each server, as I do have power issues here in my country. If it runs it will check if a backup was completed on the same day, if so, it will skip. Each time it runs, it only rsyncs the changes. First time will take a while though.

    It does need rsync, tar, gzip and an SSH key pair to work.

    The idea is multi forked.
    1, I have daily/weekly/monthly backups, so if a client calls and cries, oh he accidentally deleted some important webpage, email etc, I can recover it.
    2. I have a local back up that is off site, so if anything happens with regards to the datacenter/cloud provider/whatever, I can quickly get my clients back up and running.
    3. I wanted to be notified via Telegram when a backup is completed, and receive some basics stats about the backup. (Telegram API is needed - but it's free so don't worry).

    It's important to note, a back up on the same VM is NOT A BACKUP!!! If the VM goes down, so does the backup. Offsite is always king.

    You can check it out at: https://git.zaks.web.za/thisiszeev/linux-server-tools

    Due to power issues in my country, the server may be down. Just wait 2 hours and try again. I am working towards getting some new batteries for my inverter.

    I have a lot of other useful server scripts that I am going to add to that same repository over time, so check back often. But I will post here as well when I add/update.

    Any feedback, positive and negative, is more than welcome. Just no flames, I burn easy.
     
  2. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Better be in tips / tricks board though I would prefer the scripts or their code are attached together here instead of a git link that is down / will be down.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    I've moved the thread to tips & tricks forum.
     
  4. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    for the mysql backups, couldn't you just use automysqlbackup?
     
    ahrasis and Taleman like this.
  5. thisiszeev

    thisiszeev Member

    I will gladly post the two scripts in following replies.
     
  6. thisiszeev

    thisiszeev Member

    I see I can attach them to the reply for download... so, see attached.
     

    Attached Files:

Share This Page