Skip to content

Instantly share code, notes, and snippets.

@rakesh-mohanta
Created March 5, 2016 07:28
Show Gist options
  • Select an option

  • Save rakesh-mohanta/c70a259b692c2d6ef356 to your computer and use it in GitHub Desktop.

Select an option

Save rakesh-mohanta/c70a259b692c2d6ef356 to your computer and use it in GitHub Desktop.

Revisions

  1. Chris Hough revised this gist Feb 8, 2013. 5 changed files with 35 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
    35 changes: 35 additions & 0 deletions logrotate.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # see "man logrotate" for details
    # rotate log files weekly
    daily

    # keep 2 weeks worth of backlogs
    rotate 1

    # create new (empty) log files after rotating old ones
    create

    # use the date in backlog filenames
    dateext

    # compress backlogs with a delay
    compress

    # packages drop log rotation information into this directory
    include /etc/logrotate.d

    # no packages own wtmp, or btmp -- we'll rotate them here
    /var/log/wtmp {
    missingok
    weekly
    create 0664 root utmp
    rotate 7
    }

    /var/log/btmp {
    missingok
    weekly
    create 0664 root utmp
    rotate 7
    }

    # system-specific logs may be configured here
    File renamed without changes.
  2. Chris Hough revised this gist Jan 13, 2013. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion backup-databases
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ DBPwd="[user password]";

    for DB in $DBList;
    do
    21mysqldump --opt -u$DBUser -p$DBPwd --add-drop-table --lock-tables --databases $DB > $BackUpDIR$DateStamp.$DB.sql;
    mysqldump --opt -u$DBUser -p$DBPwd --add-drop-table --lock-tables --databases $DB > $BackUpDIR$DateStamp.$DB.sql;
    tar zcf "$BackUpDIR$DateStamp.DB.$DB.tar.gz" -P $BackUpDIR$DateStamp.$DB.sql;
    rm -rf $BackUpDIR$DateStamp.$DB.sql;
    mysqldump --opt -u$DBUser -p$DBPwd --add-drop-table --lock-tables $DB > $BackUpDIR$DateStamp.$DB.tbls.sql;
    2 changes: 1 addition & 1 deletion backup-wordpress-site-files
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ DateStamp=$(date +"%Y%m%d");

    for Site in $SiteList;
    do
    21#backup all files, however, exclude the rackspace cloud cdn if you are using it
    #backup all files, however, exclude the rackspace cloud cdn if you are using it
    tar zcf "$BackUpDIR$DateStamp.website.code.$Site.tar.gz" -P $SrvDir$Site --exclude "$SrvDir$Site/wp-content-cloudfiles";
    done
    #-----------------------------------------------------------------------
  3. Chris Hough revised this gist Jan 13, 2013. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions backup-cleanup
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/bin/bash
    #start
    #-----------------------------------------------------------------------
    find /srv/backup/daily/databases/ -name '*.gz' -mtime +7 | xargs rm -f;
    find /srv/backup/daily/websites/ -name '*.gz' -mtime +7 | xargs rm -f;
    # Are Weekly Backups Implemented?
    # find /srv/backup/weekly/ -name '*.gz' -mtime +30 | xargs rm -f;
    #-----------------------------------------------------------------------
    #end

    # Example Schedule
    # Remove Backups Greater than 7 Days Old Daily @ 01:00 AM
    # 00 01 * * * root /etc/cron.daily/backup-cleanup
  4. Chris Hough renamed this gist Jan 13, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. Chris Hough revised this gist Jan 13, 2013. 1 changed file with 22 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/bin/bash
    #start
    #-----------------------------------------------------------------------
    #verify directory structure exists prior to running this job
    BackUpDIR="/srv/backup/daily/websites/";
    SrvDir="/srv/www/";
    #Format of SiteList="sitefolder1 sitefolder2 sitefolder3"
    SiteList="[sitefolders]";
    DateStamp=$(date +"%Y%m%d");

    for Site in $SiteList;
    do
    21#backup all files, however, exclude the rackspace cloud cdn if you are using it
    tar zcf "$BackUpDIR$DateStamp.website.code.$Site.tar.gz" -P $SrvDir$Site --exclude "$SrvDir$Site/wp-content-cloudfiles";
    done
    #-----------------------------------------------------------------------
    #end

    # Example Schedule
    # Backup Wordpress Site Files Daily @ 12:45 AM
    # 45 00 * * * root /etc/cron.daily/backup-wordpress-site-files

  6. Chris Hough created this gist Jan 13, 2013.
    28 changes: 28 additions & 0 deletions backup-databases
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/bin/bash
    #start
    #-----------------------------------------------------------------------
    #verify directory structure exists prior to running this job
    BackUpDIR="/srv/backup/daily/databases/";
    DateStamp=$(date +"%Y%m%d");

    #Format of DBList="db1 db2 db3 db4"
    DBList="[dbname]";
    #I have a server system administrator account with access to all dbs, typically named sysadmin
    DBUser="[user with db permissions like sysadmin]";
    DBPwd="[user password]";

    for DB in $DBList;
    do
    21mysqldump --opt -u$DBUser -p$DBPwd --add-drop-table --lock-tables --databases $DB > $BackUpDIR$DateStamp.$DB.sql;
    tar zcf "$BackUpDIR$DateStamp.DB.$DB.tar.gz" -P $BackUpDIR$DateStamp.$DB.sql;
    rm -rf $BackUpDIR$DateStamp.$DB.sql;
    mysqldump --opt -u$DBUser -p$DBPwd --add-drop-table --lock-tables $DB > $BackUpDIR$DateStamp.$DB.tbls.sql;
    tar zcf "$BackUpDIR$DateStamp.DB.$DB.tbls.tar.gz" -P $BackUpDIR$DateStamp.$DB.tbls.sql;
    rm -rf $BackUpDIR$DateStamp.$DB.tbls.sql;
    done
    #-----------------------------------------------------------------------
    #end

    # Example Schedule
    # Backup Databases Daily @ 12:30 AM
    # 30 00 * * * root /etc/cron.daily/backup-databases
    17 changes: 17 additions & 0 deletions server-reboot
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/bin/bash
    #start
    #-----------------------------------------------------------------------

    #delete nginx cache if exists
    rm -rf /var/cache/nginx
    #restart server
    DateStamp=$(date +"%Y%m%d %k:%M:%S");
    echo $DateStamp >> /var/log/cron.reboot.log;
    /sbin/shutdown -r now

    #-----------------------------------------------------------------------
    #end

    # Example Schedule
    # Reboot Server Daily @ 1:30 AM
    # 30 01 * * * root /etc/cron.daily/server-reboot