Basic Autonomous Backup Script



  • ----------------------------------------------Attach NFS share-----------------------------------------
    Make sure you are in the root directory

    Makes directory nfs#

    1. root@FOGServer:~# mkdir /nfs

    #Mount Shared Directory (from Client)#
    2a) root@FOGServer:~# mount -o soft,intr,rsize=8192,wsize=8192 \ {ENTER}

    2b) <ip address>:/share location /nfs {ENTER}

    #Mount NFS Automatically After Reboot#

    1. Navigate to /etc/fstab and add the following line:
      <ip address>:/share location /nfs nfs soft,intr,rsize=8192,wsize=8192

    Notes:
    {ENTER} = Press Enter. It’s not code.
    Example of my ip address layout: 192.168.1.2:/mnt/Location/FOGDB
    Personally I use a mount point in NAS4Free for my nfs share

    ---------------------------------Backup Script and Cron Task-----------------------------------------

    1a) Create a backup script and name it fogbackup.sh
    1b) Include the following contents:

    #!/bin/sh
    dte=date +%F
    backup="/nfs/${dte}.sql";
    echo " Starting backup…";
    echo " Backup Location:“
    echo " $backup”;
    sleep 5;
    mysqldump --host=localhost --user=root --allow-keywords -f fog > $backup
    echo " Backup completed."

    1c) Add fogbackup.sh to folder /etc/cron.daily

    1. Rename fogbackup.sh to fogbackup

    2. Make fogbackup executable for everyone by running chmod +x fogbackup

    3. Navigate to /etc/crontab and edit crontab to include: 00 4 * * * root /etc/cron.daily/fogbackup

    Save and Restart

    That should be it.


 

429
Online

41.5k
Users

12.0k
Topics

113.5k
Posts