37 lines
1.1 KiB
Python
Executable File
37 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Send home router backup archive via SMTP."""
|
|
import smtplib
|
|
from email.mime.multipart import MIMEMultipart
|
|
from email.mime.text import MIMEText
|
|
from email.mime.application import MIMEApplication
|
|
import sys
|
|
import os
|
|
|
|
pw = open("/root/.config/himalaya/g-germainebrown.pass").read().strip()
|
|
|
|
archive_path = "/root/.hermes/backups/home-router_20260703.tar.gz"
|
|
|
|
msg = MIMEMultipart()
|
|
msg["From"] = "g@germainebrown.com"
|
|
msg["To"] = "g@germainebrown.com"
|
|
msg["Subject"] = "Home Router Backup"
|
|
|
|
body = MIMEText(
|
|
"Attached: home MikroTik backup export (terse config + log + system info).\n"
|
|
"Router: CCR2004-16G-2S+ (7.18.2)\n"
|
|
f"Archive size: {os.path.getsize(archive_path) / 1024:.1f} KB\n"
|
|
)
|
|
msg.attach(body)
|
|
|
|
with open(archive_path, "rb") as f:
|
|
att = MIMEApplication(f.read(), _subtype="gzip")
|
|
att.add_header("Content-Disposition", "attachment", filename="home-router_20260703.tar.gz")
|
|
msg.attach(att)
|
|
|
|
with smtplib.SMTP("mail.germainebrown.com", 2525) as s:
|
|
s.starttls()
|
|
s.login("g@germainebrown.com", pw)
|
|
s.send_message(msg)
|
|
|
|
print("Email sent successfully")
|