Install command
Provided
A Stop hook that syncs your changed files to cloud storage when a Claude Code session ends, using rclone to push to S3, Google Cloud Storage, or any of its 70+ supported backends.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Provided
Config snippet
Provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
0/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
3 safety and 3 privacy notes across 4 risk areas. Review closely: credentials & tokens, network access.
#!/usr/bin/env bash
echo "☁️ Starting cloud backup process..." >&2
# Generate timestamped backup directory name
BACKUP_DIR="claude-backup-$(date +%Y%m%d_%H%M%S)"
# Get list of modified files
MODIFIED_FILES=$(git diff --name-only 2>/dev/null)
if [ -z "$MODIFIED_FILES" ]; then
echo "📂 No modified files to backup" >&2
exit 0
fi
echo "📦 Found modified files to backup" >&2
# Try AWS S3 first
if command -v aws >/dev/null 2>&1 && [[ -n "$AWS_BACKUP_BUCKET" ]]; then
echo "📦 Backing up to AWS S3..." >&2
if echo "$MODIFIED_FILES" | tar -czf - -T - | aws s3 cp - "s3://$AWS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz"; then
echo "✅ Successfully backed up to S3: $AWS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz" >&2
exit 0
else
echo "❌ AWS S3 backup failed" >&2
fi
fi
# Try Google Cloud Storage
if command -v gcloud >/dev/null 2>&1 && [[ -n "$GCS_BACKUP_BUCKET" ]]; then
echo "📦 Backing up to Google Cloud Storage..." >&2
if echo "$MODIFIED_FILES" | tar -czf - -T - | gsutil cp - "gs://$GCS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz"; then
echo "✅ Successfully backed up to GCS: $GCS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz" >&2
exit 0
else
echo "❌ Google Cloud backup failed" >&2
fi
fi
# Try rclone as universal fallback
if command -v rclone >/dev/null 2>&1; then
echo "📦 Backing up using rclone..." >&2
TEMP_BACKUP="/tmp/$BACKUP_DIR.tar.gz"
if echo "$MODIFIED_FILES" | tar -czf "$TEMP_BACKUP" -T - && rclone copy "$TEMP_BACKUP" remote:backups/; then
echo "✅ Successfully backed up using rclone" >&2
rm -f "$TEMP_BACKUP"
exit 0
else
echo "❌ rclone backup failed" >&2
rm -f "$TEMP_BACKUP"
fi
fi
echo "⚠️ No cloud storage provider configured or available" >&2
echo "💡 Configure AWS_BACKUP_BUCKET, GCS_BACKUP_BUCKET, or rclone to enable cloud backup" >&2
exit 1{
"hooks": {
"stop": {
"script": "./.claude/hooks/cloud-backup-on-session-stop.sh"
}
}
}.claude/settings.local.json~/.claude/settings.json.claude/settings.json{
"hooks": {
"stop": {
"script": "./.claude/hooks/cloud-backup-on-session-stop.sh"
}
}
}
#!/usr/bin/env bash
echo "☁️ Starting cloud backup process..." >&2
# Generate timestamped backup directory name
BACKUP_DIR="claude-backup-$(date +%Y%m%d_%H%M%S)"
# Get list of modified files
MODIFIED_FILES=$(git diff --name-only 2>/dev/null)
if [ -z "$MODIFIED_FILES" ]; then
echo "📂 No modified files to backup" >&2
exit 0
fi
echo "📦 Found modified files to backup" >&2
# Try AWS S3 first
if command -v aws >/dev/null 2>&1 && [[ -n "$AWS_BACKUP_BUCKET" ]]; then
echo "📦 Backing up to AWS S3..." >&2
if echo "$MODIFIED_FILES" | tar -czf - -T - | aws s3 cp - "s3://$AWS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz"; then
echo "✅ Successfully backed up to S3: $AWS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz" >&2
exit 0
else
echo "❌ AWS S3 backup failed" >&2
fi
fi
# Try Google Cloud Storage
if command -v gcloud >/dev/null 2>&1 && [[ -n "$GCS_BACKUP_BUCKET" ]]; then
echo "📦 Backing up to Google Cloud Storage..." >&2
if echo "$MODIFIED_FILES" | tar -czf - -T - | gsutil cp - "gs://$GCS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz"; then
echo "✅ Successfully backed up to GCS: $GCS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz" >&2
exit 0
else
echo "❌ Google Cloud backup failed" >&2
fi
fi
# Try rclone as universal fallback
if command -v rclone >/dev/null 2>&1; then
echo "📦 Backing up using rclone..." >&2
TEMP_BACKUP="/tmp/$BACKUP_DIR.tar.gz"
if echo "$MODIFIED_FILES" | tar -czf "$TEMP_BACKUP" -T - && rclone copy "$TEMP_BACKUP" remote:backups/; then
echo "✅ Successfully backed up using rclone" >&2
rm -f "$TEMP_BACKUP"
exit 0
else
echo "❌ rclone backup failed" >&2
rm -f "$TEMP_BACKUP"
fi
fi
echo "⚠️ No cloud storage provider configured or available" >&2
echo "💡 Configure AWS_BACKUP_BUCKET, GCS_BACKUP_BUCKET, or rclone to enable cloud backup" >&2
exit 1
Complete hook script that backs up modified files to cloud storage when session ends using AWS S3, GCS, or rclone
#!/usr/bin/env bash
echo "Starting cloud backup process..." >&2
BACKUP_DIR="claude-backup-$(date +%Y%m%d_%H%M%S)"
MODIFIED_FILES=$(git diff --name-only 2>/dev/null)
if [ -z "$MODIFIED_FILES" ]; then
echo "No modified files to backup" >&2
exit 0
fi
if command -v aws >/dev/null 2>&1 && [[ -n "$AWS_BACKUP_BUCKET" ]]; then
echo "$MODIFIED_FILES" | tar -czf - -T - | aws s3 cp - "s3://$AWS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz"
if [ $? -eq 0 ]; then
echo "Successfully backed up to S3" >&2
exit 0
fi
fi
exit 1
Complete hook configuration for .claude/settings.json to enable cloud backup when session stops
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "./.claude/hooks/cloud-backup-on-session-stop.sh"
}
]
}
]
}
}
Hook script using rclone for universal cloud provider support with progress reporting
#!/usr/bin/env bash
echo "Starting cloud backup..." >&2
BACKUP_DIR="claude-backup-$(date +%Y%m%d_%H%M%S)"
MODIFIED_FILES=$(git diff --name-only 2>/dev/null)
if [ -z "$MODIFIED_FILES" ]; then exit 0; fi
TEMP_BACKUP="/tmp/$BACKUP_DIR.tar.gz"
echo "$MODIFIED_FILES" | tar -czf "$TEMP_BACKUP" -T -
if command -v rclone >/dev/null 2>&1; then
rclone copy "$TEMP_BACKUP" remote:backups/ --progress 2>&1
rm -f "$TEMP_BACKUP"
fi
exit 0
Enhanced hook script that uses S3 Infrequent Access storage class for cost optimization
#!/usr/bin/env bash
echo "Starting cloud backup..." >&2
BACKUP_DIR="claude-backup-$(date +%Y%m%d_%H%M%S)"
MODIFIED_FILES=$(git diff --name-only --diff-filter=ACMR 2>/dev/null)
if [ -z "$MODIFIED_FILES" ]; then exit 0; fi
if command -v aws >/dev/null 2>&1 && [[ -n "$AWS_BACKUP_BUCKET" ]]; then
echo "$MODIFIED_FILES" | tar -czf - -T - | \
aws s3 cp - "s3://$AWS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz" \
--storage-class STANDARD_IA 2>&1
if [ $? -eq 0 ]; then
echo "Backed up to S3 with Infrequent Access storage class" >&2
exit 0
fi
fi
exit 1
Hook script with timeout protection and file count limit to prevent hanging on large backups
#!/usr/bin/env bash
echo "Starting cloud backup..." >&2
BACKUP_DIR="claude-backup-$(date +%Y%m%d_%H%M%S)"
MODIFIED_FILES=$(git diff --name-only 2>/dev/null | head -100)
if [ -z "$MODIFIED_FILES" ]; then exit 0; fi
if command -v aws >/dev/null 2>&1 && [[ -n "$AWS_BACKUP_BUCKET" ]]; then
timeout 60s sh -c "echo \"$MODIFIED_FILES\" | tar -czf - -T - | aws s3 cp - \"s3://$AWS_BACKUP_BUCKET/$BACKUP_DIR.tar.gz\"" 2>&1
if [ $? -eq 0 ]; then
echo "Backup completed successfully" >&2
exit 0
fi
fi
exit 1
Verify hook script is executable with chmod +x and registered in .claude/settings.json. Check hook script path matches config. Ensure session ends cleanly without force quit. Test hook manually: bash hook-script.sh. Verify Stop hook type is correct in configuration.
Configure AWS_BACKUP_BUCKET environment variable in .env file. Verify AWS credentials with aws s3 ls. Check IAM permissions allow s3:PutObject action on target bucket. Verify bucket exists: aws s3 ls s3://bucket-name. Check AWS region configuration: aws configure get region.
Ensure files are tracked by git. Run git status to verify changes exist. Stage files with git add if needed. Check hook runs after file operations complete, not during. Use git diff --name-only --diff-filter=ACMR to include all modified files.
Use .gitignore to exclude node_modules and build artifacts from git tracking. Consider implementing file size filtering in hook script. Add timeout parameter to tar command: timeout 60s tar. Limit file count: git diff --name-only | head -100. Use rclone with --max-size option.
Hook tries AWS S3 first, then Google Cloud, then rclone. Check AWS_BACKUP_BUCKET and GCS_BACKUP_BUCKET variables are set. Verify aws or gcloud CLI tools are in PATH and authenticated. Check exit codes: aws s3 cp returns 0 on success. Review error messages without 2>&1 redirection.
Verify tar archive integrity: tar -tzf backup.tar.gz. Check network connectivity during upload. Use checksum verification: rclone copy --checksum. Test with small file set first. Verify cloud storage provider supports streaming uploads. Check disk space on /tmp for temporary archives.
Configure rclone remote: rclone config. Verify remote configuration: rclone listremotes. Test connection: rclone lsd remote:. Check credentials are valid: rclone about remote:. Use rclone config show remote to verify settings.
Add timeout wrapper: timeout 30s backup-command. Limit files backed up: git diff --name-only | head -50. Use compression level: tar -czf with gzip -1 for faster compression. Consider async backup: run backup in background. Exclude large files: --exclude "*.log" --exclude "node_modules".
Show that Cloud Backup On Session Stop - Hooks is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/hooks/cloud-backup-on-session-stop)Cloud Backup On Session Stop - Hooks side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
| Field | A Stop hook that syncs your changed files to cloud storage when a Claude Code session ends, using rclone to push to S3, Google Cloud Storage, or any of its 70+ supported backends. Open dossier | Automatically creates timestamped backups of files before modification to prevent data loss. This hook runs before file editing operations (Edit, Write, Multiedit) and creates versioned backups in a centralized .backups directory with ISO 8601-compliant timestamps including nanoseconds for collision prevention. Open dossier | Validates AWS CloudFormation templates for syntax errors and best practices using cfn-lint v1.40.4+ and AWS CLI v2.27.54+. Open dossier | Collects and reports detailed metrics about the coding session when Claude stops. Open dossier |
|---|---|---|---|---|
| Next steps | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed | Source-backed |
| Submitter | — | — | — | — |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | ||
| Category | hooks | hooks | hooks | hooks |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored | JSONbored |
| Added | 2025-09-19 | 2025-09-19 | 2025-09-19 | 2025-09-19 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Runs automatically at session end and can create compressed archives of modified git files. Uploads backups through AWS CLI, Google Cloud SDK, or rclone when those tools and bucket variables are configured. Writes a temporary archive under /tmp when using the rclone fallback and removes it after the copy attempt. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. |
| Privacy notes | ✓Sends modified file contents to the configured cloud storage destination. Uses locally configured cloud credentials and bucket environment variables but does not define or manage them. Backup archives may include source code, docs, generated files, and any unignored local changes listed by git diff. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. |
| Prerequisites | — none listed | — none listed | — none listed | — none listed |
| Install | | | | |
| Config | | | | |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Configure Claude Code to run on Amazon Bedrock with correct AWS auth.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.