diff --git a/cellar-azure-backups/.funcignore b/cellar-azure-backups/.funcignore new file mode 100644 index 0000000..5179222 --- /dev/null +++ b/cellar-azure-backups/.funcignore @@ -0,0 +1,7 @@ +*.js.map +*.ts +.git* +.vscode +local.settings.json +test +tsconfig.json \ No newline at end of file diff --git a/cellar-azure-backups/.gitignore b/cellar-azure-backups/.gitignore new file mode 100644 index 0000000..772851c --- /dev/null +++ b/cellar-azure-backups/.gitignore @@ -0,0 +1,94 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TypeScript output +dist +out + +# Azure Functions artifacts +bin +obj +appsettings.json +local.settings.json \ No newline at end of file diff --git a/cellar-azure-backups/MonitoringDeadHTTPTrigger/function.json b/cellar-azure-backups/MonitoringDeadHTTPTrigger/function.json new file mode 100644 index 0000000..7eb1f8f --- /dev/null +++ b/cellar-azure-backups/MonitoringDeadHTTPTrigger/function.json @@ -0,0 +1,19 @@ +{ + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "methods": [ + "get", + "post" + ] + }, + { + "type": "http", + "direction": "out", + "name": "res" + } + ] +} diff --git a/cellar-azure-backups/MonitoringDeadHTTPTrigger/index.js b/cellar-azure-backups/MonitoringDeadHTTPTrigger/index.js new file mode 100644 index 0000000..ff0f3ed --- /dev/null +++ b/cellar-azure-backups/MonitoringDeadHTTPTrigger/index.js @@ -0,0 +1,11 @@ +module.exports = async function (context, req) { + context.log('JavaScript HTTP trigger function processed a request.'); + + const name = (req.query.name || (req.body && req.body.name)); + const responseMessage = req; + + context.res = { + // status: 200, /* Defaults to 200 */ + body: responseMessage + }; +} \ No newline at end of file diff --git a/cellar-azure-backups/MonitoringDeadHTTPTrigger/sample.dat b/cellar-azure-backups/MonitoringDeadHTTPTrigger/sample.dat new file mode 100644 index 0000000..2e60943 --- /dev/null +++ b/cellar-azure-backups/MonitoringDeadHTTPTrigger/sample.dat @@ -0,0 +1,3 @@ +{ + "name": "Azure" +} \ No newline at end of file diff --git a/cellar-azure-backups/TimerTrigger1/function.json b/cellar-azure-backups/TimerTrigger1/function.json new file mode 100644 index 0000000..178c0ef --- /dev/null +++ b/cellar-azure-backups/TimerTrigger1/function.json @@ -0,0 +1,10 @@ +{ + "bindings": [ + { + "name": "myTimer", + "type": "timerTrigger", + "direction": "in", + "schedule": "0 */12 * * * *" + } + ] +} diff --git a/cellar-azure-backups/TimerTrigger1/index.js b/cellar-azure-backups/TimerTrigger1/index.js new file mode 100644 index 0000000..cfc218b --- /dev/null +++ b/cellar-azure-backups/TimerTrigger1/index.js @@ -0,0 +1,9 @@ +module.exports = async function (context, myTimer) { + var timeStamp = new Date().toISOString(); + + if (myTimer.isPastDue) + { + context.log('JavaScript is running late!'); + } + context.log('JavaScript timer trigger function ran!', timeStamp); +}; \ No newline at end of file diff --git a/cellar-azure-backups/TimerTrigger1/readme.md b/cellar-azure-backups/TimerTrigger1/readme.md new file mode 100644 index 0000000..8dd07e0 --- /dev/null +++ b/cellar-azure-backups/TimerTrigger1/readme.md @@ -0,0 +1,11 @@ +# TimerTrigger - JavaScript + +The `TimerTrigger` makes it incredibly easy to have your functions executed on a schedule. This sample demonstrates a simple use case of calling your function every 5 minutes. + +## How it works + +For a `TimerTrigger` to work, you provide a schedule in the form of a [cron expression](https://en.wikipedia.org/wiki/Cron#CRON_expression)(See the link for full details). A cron expression is a string with 6 separate expressions which represent a given schedule via patterns. The pattern we use to represent every 5 minutes is `0 */5 * * * *`. This, in plain text, means: "When seconds is equal to 0, minutes is divisible by 5, for any hour, day of the month, month, day of the week, or year". + +## Learn more + + Documentation \ No newline at end of file diff --git a/cellar-azure-backups/TimerTrigger1/sample.dat b/cellar-azure-backups/TimerTrigger1/sample.dat new file mode 100644 index 0000000..e69de29 diff --git a/cellar-azure-backups/host.json b/cellar-azure-backups/host.json new file mode 100644 index 0000000..6ab6643 --- /dev/null +++ b/cellar-azure-backups/host.json @@ -0,0 +1,15 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "samplingSettings": { + "isEnabled": true, + "excludedTypes": "Request" + } + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[1.*, 2.0.0)" + } +} diff --git a/cellar-azure-backups/package-lock.json b/cellar-azure-backups/package-lock.json new file mode 100644 index 0000000..947a604 --- /dev/null +++ b/cellar-azure-backups/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "cellar-azure-backups", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/cellar-azure-backups/package.json b/cellar-azure-backups/package.json new file mode 100644 index 0000000..88b0877 --- /dev/null +++ b/cellar-azure-backups/package.json @@ -0,0 +1,11 @@ +{ + "name": "cellar-azure-backups", + "version": "1.0.0", + "description": "", + "scripts": { + "start": "func start", + "test": "echo \"No tests yet...\"" + }, + "dependencies": {}, + "devDependencies": {} +} diff --git a/cellar-azure-backups/proxies.json b/cellar-azure-backups/proxies.json new file mode 100644 index 0000000..b385252 --- /dev/null +++ b/cellar-azure-backups/proxies.json @@ -0,0 +1,4 @@ +{ + "$schema": "http://json.schemastore.org/proxies", + "proxies": {} +} diff --git a/cellar-influxdb/backup.sh b/cellar-influxdb/backup.sh index f663a59..6f9ecfa 100755 --- a/cellar-influxdb/backup.sh +++ b/cellar-influxdb/backup.sh @@ -1,10 +1,9 @@ -#!/bin/sh +#!/bin/bash -influx backup $BACKUP_NAME --token $CELLAR_ADMIN_TOKEN --host $CELLAR_HOST +BACKUP_NAME=$(date +'%d-%m-%Y-%H') +echo "Creating $BACKUP_NAME.zip" + +cd /home/julien/backups +influx backup $BACKUP_NAME --token $CELLAR_ADMIN_TOKEN zip -r $BACKUP_NAME.zip $BACKUP_NAME -az storage blob upload \ - --account-name "cellarbackupstorage" \ - --container-name "cellar-backups" \ - --name $BACKUP_NAME.zip \ - --file $BACKUP_NAME.zip \ - --auth-mode login \ No newline at end of file +rm -r $BACKUP_NAME \ No newline at end of file