ArchSetu
ArchSetu
ArchSetuToolsLinuxBackup Script Generator
Free tool

Backup Script Generator

Source, destination, compression, and retention - a complete, runnable backup script for Bash or PowerShell.

#!/bin/bash
# Backup script generated by ArchSetu
# Backs up "/path/to/source" to "/path/to/backups", keeping the last 7 backups.
set -euo pipefail

SOURCE="/path/to/source"
DEST="/path/to/backups"
RETENTION=7
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_NAME="backup_$TIMESTAMP.tar.gz"

# Make sure the destination directory exists
mkdir -p "$DEST"

# Create the compressed archive
tar -czf "$DEST/$BACKUP_NAME" "$SOURCE"
echo "Created $DEST/$BACKUP_NAME"

# Delete old backups beyond the retention count
cd "$DEST"
ls -1t backup_*.tar.gz 2>/dev/null | tail -n +$((RETENTION + 1)) | xargs -r rm --
echo "Backup complete - keeping the 7 most recent backups."

To automate with cron

Save the script to /path/to/backup.sh, make it executable (chmod +x), then add this line via crontab -e:

0 2 * * * /path/to/backup.sh

Was this tool helpful?

See this same kind of analysis applied to your whole repository

Call graphs, dead code, blast radius, and a health score. Results in 60 seconds, free.

Analyze a repository

Runs entirely in your browser. Nothing is stored. Free forever.

Powered by ArchSetu