Giter Club home page Giter Club logo

google-compute-snapshot's Introduction

Google (gcloud) Compute Engine Snapshot

Overview

  • Takes a daily snapshot of the primary disk without any user input

  • Deletes all snapshots that are older than 7 days (default)

  • [OPTIONAL] Snapshots can be kept for > 7 days

      Usage: ./snapshot.sh [-d <days>]
    
      Options:
    
         -d  Number of days to keep snapshots. Snapshots older than this number deleted.
             Default if not set: 7 [OPTIONAL]
    

Prerequisites

Limitations

  • Only works for the primary disk on VM
  • Only manages snapshots created by the script

Recommended Setup

  • Load the script on to the VM (do not run it from a remote source)

  • Create a /var/log/cron directory for all cron outputs

  • Create /var/log/cron/snapshot.log

  • Change group to "adm":

    # chgrp adm /var/log/cron/snapshot.log

  • Change permissions on the "snapshot.log" file:

    # chmod 664 /var/log/cron/snapshot.log

  • Run the script from a cronjob. Note this must be done as whatever user has access to gcloud compute (usually the Google user that created the VM):

      0 05 * * * /path/to/snapshot.sh >> /var/log/cron/snapshot.log 2>&1
    
  • Add the /var/log/cron directory folder to logrotate: /etc/logrotate.d/cron

      /var/log/cron/*.log {
          daily
          missingok
          rotate 14
          compress
          notifempty
          create 664 root adm
          sharedscripts
      }
    

Downloading the script and opening in Windows?

If you download the script and open it on a Windows machine, that may add windows character's to the file: jacksegal#1.

google-compute-snapshot's People

Contributors

dborin avatar jacksegal avatar joealamo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.