ATRC Windows Backup & Restore Utility

A robust, automated file backup solution designed for Windows environments (with backward compatibility for Windows 7). It securely transfers files to a remote SFTP server, tracks versions using a local SQLite database, implements a "Smart GFS" (Grandfather-Father-Son) retention policy, and provides built-in Web UI, Email, and Nextcloud reporting.

1. Features

2. Installation & Setup

  1. Create the Working Directory: The program defaults to using C:\Program Files\atrc\backup. You should create this folder manually or let the program create it on first run.
  2. Run the Executable: Right-click the atrc_windows_backup_to_sftp_with_tracking.exe and select "Run as Administrator". This is required to read protected files (like those in C:\Users) and to write to the Program Files directory.
  3. Configure config.txt: On the first run, the program will generate a default config.txt in C:\Program Files\atrc\backup\. Open this file with Notepad and fill in your credentials.

Example config.txt

# atrc backup configuration (CRLF format)
sftp_host=192.168.1.4
sftp_port=22
sftp_user=test
sftp_password=your_sftp_password_here
web_bind=0.0.0.0:8080

# Nextcloud Upload URL for Status Updates
# Provide the public share link (File Drop) or WebDAV URL here
nextcloud_status_upload_url=https://your-nextcloud-domain/index.php/s/YOUR_SHARE_TOKEN

# Email Reports
smtp_host=mail.atrc.net.pk
smtp_port=587
smtp_user=backup_mailer
smtp_password=your_email_password_here
email_from=backup_mailer@atrc.net.pk
email_to=admin@atrc.net.pk

# Add specific folders to back up in addition to auto-scanning all local drives:
# extra_source=C:\MySpecialProject

3. Command-Line Usage

The program runs in a loop (backup by default) but accepts flags to change its behavior. Open Command Prompt as Administrator to use these.

Basic Backup (Default)

atrc_windows_backup_to_sftp_with_tracking.exe

What it does: Scans all local drives, compares files against the database, uploads changed files, prunes old versions, emails a report, uploads a status report to Nextcloud, and then exits.
Cooldown: By default, it will refuse to run if it was executed less than 1 hour ago (it emails and uploads a "Skipped" notification). It also ignores files modified in the last 6 hours to prevent backing up files currently being written to.

Force Update (--update-now)

atrc_windows_backup_to_sftp_with_tracking.exe --update-now

What it does: Ignores the 1-hour run limit and the 6-hour file cooldown. It forces an immediate backup of any file that has changed.

Keep Web Server Alive (--keep-alive)

atrc_windows_backup_to_sftp_with_tracking.exe --keep-alive

What it does: Runs the backup and then keeps the program running so you can access the Web Dashboard (default: http://localhost:8080). Press Ctrl+C to stop.

Restore Files (--restore)

atrc_windows_backup_to_sftp_with_tracking.exe --restore "D:\MyRestoreFolder"

What it does:

  1. Connects to the SFTP server.
  2. Downloads the most recent tracker_*.db database.
  3. Iterates through the database and downloads the latest version of every file.
  4. Places them into the destination directory, separated by drive:

Show Help (--help)

atrc_windows_backup_to_sftp_with_tracking.exe --help

4. How It Works (Under the Hood)

5. Troubleshooting

Problem: Program immediately exits and says "Backup skipped."
Solution: It ran less than 1 hour ago. Use --update-now to force it.

Problem: "Database format changed. Please restart the program."
Solution: The program detected an older database schema. It has automatically deleted the old database. Simply run the program again.

Problem: Email fails to send.
Solution: Verify your SMTP credentials in config.txt. If the mail server has a broken SSL certificate, the program's built-in bypass should handle it, but the username/password must be exactly correct (e.g., backup_mailer@atrc.net.pk vs backup_mailer).

Problem: Nextcloud status upload fails.
Solution: Verify the nextcloud_status_upload_url in config.txt. If using a public share, ensure the share has "Allow uploading" (File Drop) enabled in the Nextcloud web interface. The program automatically tries multiple WebDAV and API endpoints, but the share must permit anonymous or token-based uploads.

Problem: "Access Denied" errors in the console.
Solution: Close the program, right-click the .exe, and select "Run as Administrator".