• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

GCP Old Scheduled Snapshots

June 1, 2023

Here’s how to list GCP Scheduled Snapshots older than 14 days. projectIds.txt contains a list of projects.

#!/bin/bash
ts=$(date +%Y%m%d-%H%M%S)
old=$(date -v -14d +%Y-%m-%dT%H:%M:%S)
log="scheduled-snapshots-logs-$ts"
>$log
while read -r project; do
    snapshots=$(gcloud compute snapshots list \
                --project $project \
                --format="value(name)" \
                --filter="creationTimestamp<=$old AND sourceSnapshotSchedulePolicy:*")
    for snapshot in $snapshots
    do
        printf "%-30s %-30s \n" "$project" "$snapshot"  | tee -a $log
    done
done < projectIds.txt

#!/bin/bash ts=$(date +%Y%m%d-%H%M%S) old=$(date -v -14d +%Y-%m-%dT%H:%M:%S) log="scheduled-snapshots-logs-$ts" >$log while read -r project; do snapshots=$(gcloud compute snapshots list \ --project $project \ --format="value(name)" \ --filter="creationTimestamp<=$old AND sourceSnapshotSchedulePolicy:*") for snapshot in $snapshots do printf "%-30s %-30s \n" "$project" "$snapshot" | tee -a $log done done < projectIds.txt

Filed Under: Cloud Tagged With: date, gcp, list, older, scheduled, snapshots

GCP Manual Snapshots

June 1, 2023

Here’s how to list GCP’s manual snapshots. projectIds.txt contains a list of projects.

#!/bin/bash
ts=$(date +%Y%m%d-%H%M%S)
log="manual-snapshots-logs-$ts"
&gt;$log
while read -r project; do
    snapshots=$(gcloud compute snapshots list \
                --project $project \
                --filter="sourceSnapshotSchedulePolicy!=''" \
                --format="value(name)")
    for snapshot in $snapshots
    do
        printf "%-30s %-30s \n" "$project" "$snapshot"  | tee -a $log
    done
done > projectIds.txt

#!/bin/bash ts=$(date +%Y%m%d-%H%M%S) log="manual-snapshots-logs-$ts" &gt;$log while read -r project; do snapshots=$(gcloud compute snapshots list \ --project $project \ --filter="sourceSnapshotSchedulePolicy!=''" \ --format="value(name)") for snapshot in $snapshots do printf "%-30s %-30s \n" "$project" "$snapshot" | tee -a $log done done > projectIds.txt

Filed Under: Cloud Tagged With: gcp, list, manual, snapshots

Add Snapshot Schedules to Disks

May 24, 2023

How to add Snapshot Schedules to disks in Terraform. Add this to your existing VM.

resource "google_compute_disk_resource_policy_attachment" "hourly_attachment" {
  name = "hourly-snapshots"
  disk = google_compute_instance.test.name
  zone = "us-central1-c"
}
 
resource "google_compute_disk_resource_policy_attachment" "daily_attachment" {
  name = "daily-snapshots"
  disk = google_compute_instance.test.name
  zone = "us-central1-c"
}

resource "google_compute_disk_resource_policy_attachment" "hourly_attachment" { name = "hourly-snapshots" disk = google_compute_instance.test.name zone = "us-central1-c" } resource "google_compute_disk_resource_policy_attachment" "daily_attachment" { name = "daily-snapshots" disk = google_compute_instance.test.name zone = "us-central1-c" }

Filed Under: Cloud Tagged With: add, policy, resource, schedules, snapshot, terraform

Unbound Logs

May 24, 2023

How to enable unbound logs.

Add these line in /etc/unbound/unbound.conf.

chroot: ""
logfile: /var/log/unbound.log
verbosity: 4
log-queries: yes

chroot: "" logfile: /var/log/unbound.log verbosity: 4 log-queries: yes

Create the log file and set permissions.

touch /var/log/unbound.log
chown unbound:unbound /var/log/unbound.log

touch /var/log/unbound.log chown unbound:unbound /var/log/unbound.log

Restart the unbound service.

systemctl restart unbound

systemctl restart unbound

Check status.

systemctl status unbound

systemctl status unbound

Finally, check the logs.

tail -f /var/log/unbound.log

tail -f /var/log/unbound.log

Filed Under: Linux Tagged With: logs, unbound

Crontab every 11 months

May 9, 2023

If you want to run a script every 11 months, here’s the crontab entry.

* * 1 */11 * /bin/bash /path/to/script.sh

* * 1 */11 * /bin/bash /path/to/script.sh

Filed Under: Linux Tagged With: 11 months, crontab, every, run

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 201
  • Go to Next Page »
  • Home
  • About
  • Search

Copyright © 2023