Discover Centmin Mod today
Register Now

Sysadmin Which folders should I backup to make it like a snapshot of baremetal?

Discussion in 'System Administration' started by Chuong Luong, Dec 2, 2021.

  1. Chuong Luong

    Chuong Luong Member

    39
    1
    8
    Aug 8, 2019
    Ratings:
    +5
    Local Time:
    7:32 PM
    Hi,

    Before, I use DO, so everytime I want to backup, I turn off my droplet and make a snapshot.


    But now I change to a baremetal from ovh, they also provide ftp backup storage. I am so new to server admin, so I have some confusion:

    1- With centmin, which folders should I backup, so that when upgrade or change server I can restore exactly the backup state?
    2- Their support page show the usage of backing up by ftp: Using backup storage on a dedicated server

    But I don't know when to use ncftp or tar??
    3- I read the suggestion from @eva2000 about using rsnapshot + backupsy. Yet, I still don't know how to stop the server and which folders to do the backup to protect consistency of databases.

    Thank you.
     
  2. brijendrasial

    brijendrasial Active Member

    142
    115
    43
    Mar 21, 2018
    Ratings:
    +174
    Local Time:
    6:02 PM
    1.13.9
    10.0.22-MariaDB
  3. Chuong Luong

    Chuong Luong Member

    39
    1
    8
    Aug 8, 2019
    Ratings:
    +5
    Local Time:
    7:32 PM
    With this:
    Code:
    # mount -t nfs HostName:/export/ftpbackup/ServiceName /FolderMount
    The "/export/ftpbackup/ServiceName" is taken from my server, or I just create anything I want?
     
  4. eva2000

    eva2000 Administrator Staff Member

    48,826
    11,168
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,396
    Local Time:
    10:32 PM
    Nginx 1.21.x
    MariaDB 10.x
    For backups and backup scripts in general, there's a few threads on the forums and linked resources which maybe worth reading:

    Backup Specifics For Centmin Mod



    An overview of the main Centmin Mod config files are outlined at https://centminmod.com/configfiles.html and the data server migration guides below also give ideas of what commands to use and what to backup for data migration which can be useful to figure out what to backup on Centmin Mod based servers.
    Notes:
    1. Important that if you're doing backups, you must ensure you have enough free disk space on your server at the target intended backup destination directory/partition on your disk. So if you're backing up 20GB of data to /backups, ensure /backups directory exists and has enough disk free space.
      Code (Text):
      df -hT /backups
      Filesystem     Type  Size  Used Avail Use% Mounted on
      /dev/vda1      ext4   40G  8.3G   30G  23% /
      
    2. If you're saving several versions of backups i.e. 7 days worth of backups, you'd need 7x times the extra disk free space i.e. 20GB x 7 = 140GB extra disk free space.
    3. For remote backups, if it's important for backup speed, ensure your server and remote server have a fast enough network connection i.e. 1Gbit/s network on either source and remote destination servers
    4. You can use the above links and Centmin Mod migration guides as a guide and practise on test dummy hourly billed VPS servers for test runs until you're familiar with the process without touching your live server until you're comfortable to do so
    5. If you're doing email notifications for backup status or errors from Centmin Mod server, follow the Steps to ensure your site/server email doesn't end up in spam inboxes so that email notifications arrive in your inbox.
     
    Last edited: Dec 3, 2021
  5. eva2000

    eva2000 Administrator Staff Member

    48,826
    11,168
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,396
    Local Time:
    10:32 PM
    Nginx 1.21.x
    MariaDB 10.x
    For that best to google for guides on how to use them and practice on a test dummp VPS until you're comfortable.
     
  6. buik

    buik “The best traveler is one without a camera.”

    1,666
    460
    83
    Apr 29, 2016
    Flanders
    Ratings:
    +1,436
    Local Time:
    2:32 PM
    When you want a turnkey solution. You might want to look at Jetbackup et all.
    With a GUI you can easily select what you want to backup, when and where to.
     
  7. Chuong Luong

    Chuong Luong Member

    39
    1
    8
    Aug 8, 2019
    Ratings:
    +5
    Local Time:
    7:32 PM
    Thank you. Another question:

    Scenario 1: I tested backup by transferring files and sql files to a nfs volume. Turn out all the files were not preserved owner and permission.

    Scenario 2: If I use backupsy, and pay extra to install centmin on their server. When using rsycn, do my files preserve all the permission as on my original server? Logically, from your migration guide, I think they will. However, I just want to ask to make sure I understand correctly.

    Because I leaned more to the mysqldump - tar - rsycn - backupsy approach. Manual backup will be done monthly, just for high safety.
     
  8. eva2000

    eva2000 Administrator Staff Member

    48,826
    11,168
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,396
    Local Time:
    10:32 PM
    Nginx 1.21.x
    MariaDB 10.x
    How did you backup to NFS ? what tools/cmds did you use?

    Regardless of scenarios, tar and rsync are the main tools used with optional flags to preserve permissions - which in this case for both is the -p flag. From their respective command help info output
    Code (Text):
    rsync --help | grep -i permissions
     -p, --perms                 preserve permissions
         --chmod=CHMOD           affect file and/or directory permissions
    

    Code (Text):
    tar --help | grep -i permissions
                                 permissions of extracted directories until the end
          --no-same-permissions  apply the user's umask when extracting permissions
      -p, --preserve-permissions, --same-permissions
                                 extract information about file permissions
    

    rsync also has archive flag -a which includes -p
    Code (Text):
    rsync --help | grep -i 'archive'
     -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
    

    If you google for tar and rsync backup guides for file backups, you can get an idea of what to use. The migration guide also has examples at https://community.centminmod.com/threads/centmin-mod-site-data-migration-guide.10382/
     
  9. Chuong Luong

    Chuong Luong Member

    39
    1
    8
    Aug 8, 2019
    Ratings:
    +5
    Local Time:
    7:32 PM
    The baremetal from OVH provide free backup space using ftp or nfs. So, I tried mount as nfs, but when doing rsync, all the permission was gone.

    So I go with approach of using backupsy - mysqldump - rsync. However, full server backup using migration guide have some disadvantages:

    After newly setting up Centminmod (either for backup or server restore), beside these folders that need to be rsync:
    Code:
    /home/nginx/domains/
    /usr/local/nginx/conf/conf.d
    /usr/local/nginx/conf/autoprotect
    /usr/local/nginx/conf/wpincludes
    /usr/local/nginx/conf/pre-staticfiles-local-*.conf
    /usr/local/nginx/conf/ssl/cloudflare
    /usr/local/nginx/conf/ssl/
    /root/.acme.sh/
    
    These files also needed to be copied to the new server, to make sure nginx is not broken:
    Code:
    /usr/local/nginx/conf/php-wpsc.conf
    /usr/local/nginx/conf/pre-staticfiles-global.conf
    /usr/local/nginx/conf/wpcacheenabler_map.conf
    /usr/local/nginx/conf/redisupstream.conf
    Dummy file: /home/nginx/domains/abc.com/log/access.log
    
    Just a note for anyone who wants to do full server migration (for manual backup & restore) and want to keep the initial optimized config from first time installed Centmin on new server.
     
  10. eva2000

    eva2000 Administrator Staff Member

    48,826
    11,168
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,396
    Local Time:
    10:32 PM
    Nginx 1.21.x
    MariaDB 10.x
    Yes those files are conditionally created depending on centmin.sh menu option 22 Wordpress caching options you choose, so would vary depending on what you choose.

    Glad to see you're getting on top of and understanding the backups - worth learning :)