-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_local.sh
More file actions
executable file
·48 lines (40 loc) · 1.07 KB
/
Copy pathexport_local.sh
File metadata and controls
executable file
·48 lines (40 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Export local configs for transfer to another machine
# Encrypted with age - you'll be prompted for a passphrase
set -e
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
ARCHIVE="dotfiles_local_$TIMESTAMP.tar.gz.age"
TEMP_DIR=$(mktemp -d)
echo "=== Exporting Local Configs ==="
echo ""
# Files to export
FILES=(
"$HOME/.secrets"
"$HOME/.zshrc.local"
"$HOME/.ssh/config.local"
"$HOME/.gitconfig.local"
)
# Copy files that exist
for file in "${FILES[@]}"; do
if [ -f "$file" ]; then
name=$(basename "$file")
cp "$file" "$TEMP_DIR/$name"
echo " ✓ $name"
else
echo " - $(basename $file) (not found, skipping)"
fi
done
# Create tarball and encrypt with age (passphrase)
echo ""
echo "Creating encrypted archive..."
tar -czf - -C "$TEMP_DIR" . | age -p -o "$HOME/$ARCHIVE"
# Clean up temp files
rm -rf "$TEMP_DIR"
echo ""
echo "=== Export Complete ==="
echo ""
echo "Archive: ~/$ARCHIVE"
echo "Size: $(du -h "$HOME/$ARCHIVE" | cut -f1)"
echo ""
echo "Transfer securely to new machine, then run:"
echo " ./import_local.sh ~/$ARCHIVE"