Welcome to Centmin Mod Community
Register Now

Sysadmin Advice needed for backup strategy

Discussion in 'System Administration' started by Saahib, May 5, 2020.

  1. Saahib

    Saahib Member

    38
    2
    8
    Oct 8, 2017
    Ratings:
    +6
    Local Time:
    11:36 AM
    1.13
    10.2
    Hi,
    I have been using couple of centmin based servers. For backups, I was using simple mysqldump and rsync for home directory. It good but recently had to migrate to new server and it was time consuming to restore as I had all data needed for websites but not for system. Had to manually create account, add IPs (few have dedicated IPs) , create db user, upload backup of db.

    I am planning to use rsnapshot. What I am looking for something like if I have to migrate or restore, then I don't have to manually redo everything. Looking what files can be backed up that after fresh install of centmin on new server, I just replace files and upload database and things get ready.

    I have been through some threads :
    CMM Backup Script

    But I am trying to keep is as will make sh script which I can run with cron so that I know what's going on.

    Thanks.
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,417
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,692
    Local Time:
    4:06 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    For moving site data there's 2 general guides where the principles & steps of backing up and moving data is the same just slightly different for
    1. Moving Centmin Mod site data to another Centmin Mod server
    2. Moving cPanel/WHM site data to Centmin Mod server
    Those guides move alot more than just the site(s) in question but config files etc. You can use your own best judgement as to the config files and whether you want to move them or just use the fresh server setup Centmin Mod config files as they get auto optimised for the server Centmin Mod initially installed on.

    If your old site isn't centmin mod or cpanel/whm based, then those guides won't be 100% applicable. But the general overview of what needs moving and where everything is structured in Centmin Mod LEMP environment is worth reading up on.

    Also official site configuration files page explains the Centmin Mod structure of where the important files are so you can decide on what to backup.

    Manual commands can be just scripted if you learn shell/bash scripting. For example most of the commands in the 2 moving guides I linked to can eventually be scripted to be automated if you know what you're doing. So it eventually isn't about manual vs automated, but whether you understand the commands used to backup and restore your data and then scripting it.

    Some discussions related to this
     
  3. Saahib

    Saahib Member

    38
    2
    8
    Oct 8, 2017
    Ratings:
    +6
    Local Time:
    11:36 AM
    1.13
    10.2
    Thanks for pointers,
    However, I have been through all links already, I suppose I have some idea now about my need.
    But, as always, what should be sql backup strategy as it is always changing. Although servers can do away with nightly mysqldump and its not very large either.

    Rsnapshot is not going to help much if we are creating new dump file everytime as it will create new file everytime for each snapshot, correct me if I am wrong.

    I have restored from mysql data in past (after stopping mysql server), but taking snapshot of /usr/lib/mysql is something different as it will be changing always , how to handle data inconsistency ?

    I am thinking to
    1. Take weekly full backup with dump (non-incremental) as if something goes kaput with incremental backup, this one is uncompromised.
    2. Daily 4 snapshot of
    a.config files, b. /home c./var/lib/mysql

    But again this way mysql data backup may not be sane .

    Any advice ?
     
  4. redbot

    redbot Dreaming of Debmin Mod Premium Member

    33
    6
    8
    Mar 30, 2020
    Ratings:
    +15
    Local Time:
    1:06 AM
  5. eva2000

    eva2000 Administrator Staff Member

    44,417
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,692
    Local Time:
    4:06 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Looks interesting :)

    Depends on how valuable you data is to you. I backup file and database data depending on how valuable the data is. As it's non-commercial, I usually backup with my own custom written scripts every 3-8hrs depending on the data and backup a local server copy + send them off to remote Amazon S3 buckets. My Amazon S3 buckets storage has just surpassed 3TB (yes terabytes) at around US$55/month. Many folks don't realise, if you want regular and frequent highly available backups, it costs more $$$ and alot more server resources/servers than they maybe prepared to pay for :)

    If it's very important data and/or commercial, then do a combination of backup methods and not just one with MySQL replication with multiple MySQL dedicated servers for master/slave and/or clustered MySQL servers (minimum need 3-5 servers) and large disk storage space capable of doing MySQL binary log backups via a dedicated binary log server for moment in time backups which can consume 100s of gigabytes of disk space. Along with fast MySQL backup tools via Percona Xtrabackup or MariaDB Backup tools i.e. Sysadmin - MariaDB backup tool question.

    Centmin Mod premium forum members have access to dbbackup.sh for MySQL database backups too MariaDB - dbbackup.sh - quick mysql database backups for Centmin Mod stack which allows for
    • MySQL database and schema only backups + /etc/my.cnf backup
    • Multi-threaded parallel compression default pigz with options for lbzip2, pbzip2 and pxz. For single cpu core servers, falls back from pigz to gzip.
    • Amazon S3 Storage support and option to define one of three S3 storage classes (Standard, Standard – IA, and Glacier) to control your Amazon S3 storage costs and Amazon S3 availability and durability. Disabled by default.
    • Amazon S3 Upload Dry Run Mode support. Disabled by default.
    • Remote FTP/SFTP support - can define up to 3 separate FTP/SFTP locations to remotely transfer your backups for added redundancy and data safeguard.Disabled by default.
    • Backup Retention threshold set in days. Older than XX days deletion routine for both local backups and remote FTP/SFTP backups. Amazon S3 you can setup your own S3 bucket's lifecycle management in AWS Console. Example for retention threshold based deletion shown here.
    • Email and Pushover.net mobile notification options on backup runs. Disabled by default.
    • Persistent db-config.ini separate file option so custom settings survive dbbackup.sh script updates.
    • Full backup run logging to log file for diagnostic troubleshooting or historic records
    • Smarter per database character set and collation handling for backups to prevent database table corruption due to character set and mixed collations.
     
  6. Saahib

    Saahib Member

    38
    2
    8
    Oct 8, 2017
    Ratings:
    +6
    Local Time:
    11:36 AM
    1.13
    10.2
    Thanks for the mention, but here we are discussing about system level backup.

    @eva2000,
    You are right, every backup is important.

    So as per your advice, for real time backup of dbs, its better to have master-slave replication. I have plan for it, infact VM was allotted.

    Small question about rsnapshot, it looks good , its like you can have rsync with for a timeline. However, I don't see any option in rsnapshot to specify multiple backup strategy. I can see that you can specify frequency like..

    Code:
    interval     BackupA 6 
    BackupA can have 6 copies which I can then run daily using cron, translates into Daily backup with 6 copies or restore points.

    But as said, can we specify what to backup, ie. what if I want

    /home/nginx/domains to backup only once a week.
    While
    /var/lib/mysql twice daily ?

    Is it possible in rsnapshot ?


    Because as per my understanding, you can specify multiple backup points but all will be backed up whether you run daily / weekly or whatever interval backup scheme ?
     
  7. eva2000

    eva2000 Administrator Staff Member

    44,417
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,692
    Local Time:
    4:06 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    probably need to read the rsnapshot documentation and ask on their support platforms etc
    You don't want rsnapshot anywhere directly accessing /var/lib/mysql unless you want to corrupt all your mysql data. While MySQL server is running, you shouldn't be directly touching the mysql data files in that directory outside of MySQL process/tools designed to properly and safely backup/restore that data.
     
  8. Saahib

    Saahib Member

    38
    2
    8
    Oct 8, 2017
    Ratings:
    +6
    Local Time:
    11:36 AM
    1.13
    10.2
    Well, I see in other posts that you have been using snapshot, being more experienced I was expecting you to have clear idea about it. But as far as I can see in docs and info around, rsnapshot can do incremental backups ,multiple backup point but can't have multiple source with multiple interval.

    Well, yap, without stopping mysql, its bad idea to touch /var/lib/mysql .. thanks for pointing it out.

    I am now looking into Borgbackup but can't get it installed. See other thread.
     
    Last edited: May 8, 2020