<< Back to Quick Tips & Tricks

Automating Camera Backups with Go and SFTP

Published {$created} by Viggo


As a hobbyist photographer and videographer, I collect a lot of data. My security cameras, used for both home and a small rental property, are no exception. I initially set up a local NAS for storage, but I quickly realized the risks of relying on a single point of failure. I needed a reliable, offsite backup solution. I considered solutions like WeTransfer for business, but felt that wasn’s suitable for automatically archiving my security footage.

My background is primarily in Go, so I decided to build a custom backup script using the golang.org/x/crypto/ssh package. The challenge? Many tutorials focused on basic SFTP usage, but integrating key-based authentication and automated scheduling proved trickier than I expected. I needed a provider that offered robust SFTP access and reliable uptime – and that’s when I found ftpGrid.

Secure Automation with SFTP

ftpGrid’s straightforward SFTP access made writing my Go script a breeze. I opted for SSH-ED25519 key-based authentication – a more modern and secure alternative to SSH-RSA, as outlined in ftpGrid's guide on advanced SSH key authentication. The account setup was quick, and the ability to view individual account usage helped me estimate storage needs and choose an appropriate tier on the pricing page.

Here’s a simplified snippet of my Go script:

// (simplified example - error handling omitted for brevity)
package main

import (
	"fmt"
	"os"

	"golang.org/x/crypto/ssh"
)

func main() {
	host := "edgeN.ftpgrid.com"
	username := os.Getenv("FTPGRID_USERNAME")
	privateKeyPath := os.Getenv("FTPGRID_PRIVATE_KEY_PATH")

	// ... (SSH connection setup using private key from environment variables) ...
	fmt.Println("Connecting to", host)
}

Storing the username and private key path as environment variables further secured my configuration. The fact that ftpGrid offers GDPR compliance and encrypts data at rest and in transit (using TLS 1.3) gave me added peace of mind.

Reliable Backups, Zero Hassle

Integrating the Go script with cron was simple. Now, my security camera footage automatically backs up to ftpGrid, providing a secure and reliable offsite copy. The activity timeline lets me easily verify that backups are running as expected, and I can monitor bandwidth usage to optimize my backup schedule. The ability to sync or mirror data to external FTP cloud storage is a future consideration as my storage needs grow.



Keywords: developer SFTP in go lang
Free signup
© 2025 ftpGrid

ftpGrid ApS
Branebjerg 24
DK-5471
Gamby
Denmark

Looking for an all-in-one time tracking, timesheet, and invoicing solution - visit our Devanux sister company Nureti at https://nureti.com.

Preview Devanux’s upcoming project Pictoguide – a visual support tool designed to bring structure and clarity to people with ASD.