File size: 6,646 Bytes
279efce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# Backup KDE Settings

You are helping the user export and backup their KDE Plasma configuration settings.

## Task

1. **Identify KDE configuration locations:**
   ```bash
   # Main config directory
   echo "KDE Config: ~/.config/"

   # Local data directory
   echo "KDE Data: ~/.local/share/"

   # Cache directory
   echo "KDE Cache: ~/.cache/"
   ```

2. **List important KDE configuration files:**
   ```bash
   # Core KDE files
   ls -lh ~/.config/k* ~/.config/plasma* ~/.config/*rc 2>/dev/null | head -30

   # Desktop files
   ls -lh ~/.local/share/plasma* ~/.local/share/k* 2>/dev/null | head -20
   ```

3. **Create backup directory:**
   ```bash
   # Create timestamped backup directory
   BACKUP_DIR=~/.kde-backups/kde-backup-$(date +%Y%m%d-%H%M%S)
   mkdir -p "$BACKUP_DIR"
   echo "Backup directory: $BACKUP_DIR"
   ```

4. **Backup essential KDE configurations:**
   ```bash
   # Core Plasma configuration
   cp -r ~/.config/plasma* "$BACKUP_DIR/" 2>/dev/null
   cp -r ~/.config/k* "$BACKUP_DIR/" 2>/dev/null

   # Application-specific configs
   for config in kdeglobals kwinrc dolphinrc konsolerc katerc spectaclerc; do
     [ -f ~/.config/$config ] && cp ~/.config/$config "$BACKUP_DIR/"
   done

   # Desktop theme and appearance
   cp ~/.config/plasmarc "$BACKUP_DIR/" 2>/dev/null
   cp ~/.config/plasmashellrc "$BACKUP_DIR/" 2>/dev/null

   # Keyboard shortcuts
   cp ~/.config/kglobalshortcutsrc "$BACKUP_DIR/" 2>/dev/null
   cp ~/.config/khotkeysrc "$BACKUP_DIR/" 2>/dev/null
   ```

5. **Backup KDE desktop layouts:**
   ```bash
   # Plasma layouts
   cp -r ~/.local/share/plasma "$BACKUP_DIR/plasma-data" 2>/dev/null

   # Desktop scripts
   cp -r ~/.local/share/kservices5 "$BACKUP_DIR/kservices" 2>/dev/null

   # Plasmoids and widgets
   cp -r ~/.local/share/plasmashell "$BACKUP_DIR/plasmashell-data" 2>/dev/null
   ```

6. **Backup application data:**
   ```bash
   # Dolphin bookmarks and settings
   cp -r ~/.local/share/dolphin "$BACKUP_DIR/dolphin-data" 2>/dev/null

   # Konsole profiles
   cp -r ~/.local/share/konsole "$BACKUP_DIR/konsole-data" 2>/dev/null

   # KWallet (encrypted passwords)
   cp -r ~/.local/share/kwalletd "$BACKUP_DIR/kwallet-data" 2>/dev/null

   # Akonadi (if using KMail/contacts)
   # cp -r ~/.local/share/akonadi "$BACKUP_DIR/akonadi-data" 2>/dev/null
   ```

7. **Backup color schemes and themes:**
   ```bash
   # Color schemes
   cp -r ~/.local/share/color-schemes "$BACKUP_DIR/" 2>/dev/null

   # Plasma themes
   cp -r ~/.local/share/plasma/desktoptheme "$BACKUP_DIR/" 2>/dev/null

   # Icon themes
   cp -r ~/.local/share/icons "$BACKUP_DIR/" 2>/dev/null

   # Window decorations
   cp -r ~/.local/share/aurorae "$BACKUP_DIR/" 2>/dev/null
   ```

8. **Create backup manifest:**
   ```bash
   cat > "$BACKUP_DIR/BACKUP_INFO.txt" << EOF
   KDE Plasma Backup
   =================
   Date: $(date)
   Hostname: $(hostname)
   KDE Version: $(plasmashell --version)
   Qt Version: $(qmake --version | grep -i "Qt version")

   Backup Contents:
   ----------------
   $(find "$BACKUP_DIR" -type f | wc -l) files backed up
   $(du -sh "$BACKUP_DIR" | cut -f1) total size

   Configuration Files:
   $(ls -1 "$BACKUP_DIR"/*.rc "$BACKUP_DIR"/*config* 2>/dev/null | wc -l) config files

   Important Files:
   $(ls -lh "$BACKUP_DIR" | grep -E "plasma|kwin|dolphin|konsole|kdeglobals")
   EOF

   cat "$BACKUP_DIR/BACKUP_INFO.txt"
   ```

9. **Compress backup:**
   ```bash
   # Create compressed archive
   cd ~/.kde-backups
   tar czf "$(basename "$BACKUP_DIR").tar.gz" "$(basename "$BACKUP_DIR")"

   # Show results
   ls -lh "$(basename "$BACKUP_DIR").tar.gz"
   echo "Backup archived: ~/.kde-backups/$(basename "$BACKUP_DIR").tar.gz"
   ```

10. **Optional: Sync to cloud or external storage:**
    ```bash
    # Ask user if they want to copy backup elsewhere
    # Example: Copy to NAS
    # scp "$(basename "$BACKUP_DIR").tar.gz" user@nas:/backups/kde/

    # Example: Copy to external drive
    # cp "$(basename "$BACKUP_DIR").tar.gz" /mnt/external/kde-backups/
    ```

## Restoration Instructions

Create a restoration guide in the backup:
```bash
cat > "$BACKUP_DIR/RESTORE.md" << 'EOF'
# KDE Backup Restoration

## To restore this backup:

1. **Extract the archive:**
   ```bash
   cd ~/.kde-backups
   tar xzf kde-backup-TIMESTAMP.tar.gz
   ```

2. **Close all KDE applications** (important!)

3. **Restore configuration files:**
   ```bash
   cd kde-backup-TIMESTAMP
   cp -r k* plasma* *.rc ~/.config/
   ```

4. **Restore data files:**
   ```bash
   cp -r plasma-data ~/.local/share/plasma
   cp -r dolphin-data ~/.local/share/dolphin
   cp -r konsole-data ~/.local/share/konsole
   ```

5. **Restart Plasma:**
   ```bash
   kquitapp6 plasmashell && kstart plasmashell
   ```

   Or log out and back in.

## Selective Restoration

To restore only specific components:
- Shortcuts: `cp kglobalshortcutsrc ~/.config/`
- Theme: `cp plasmarc ~/.config/`
- Panel/Desktop: `cp -r plasma-data ~/.local/share/plasma`
- Dolphin: `cp -r dolphin-data ~/.local/share/dolphin`

EOF
```

## Minimal vs Complete Backup

**Minimal backup** (most important settings):
```bash
# Just essential configs
tar czf ~/.kde-backups/kde-minimal-backup.tar.gz \
  ~/.config/kdeglobals \
  ~/.config/kwinrc \
  ~/.config/plasmarc \
  ~/.config/kglobalshortcutsrc \
  ~/.local/share/plasma
```

**Complete backup** (everything):
```bash
# All KDE data
tar czf ~/.kde-backups/kde-complete-backup.tar.gz \
  ~/.config/k* \
  ~/.config/plasma* \
  ~/.local/share/plasma* \
  ~/.local/share/k* \
  --exclude="*.lock" \
  --exclude="*cache*"
```

## Scheduled Backups

Create a cron job for automatic backups:
```bash
# Add to crontab
(crontab -l 2>/dev/null; echo "0 2 * * 0 $HOME/.local/bin/backup-kde.sh") | crontab -

# Create backup script
cat > ~/.local/bin/backup-kde.sh << 'EOF'
#!/bin/bash
BACKUP_DIR=~/.kde-backups/kde-backup-$(date +%Y%m%d)
mkdir -p "$BACKUP_DIR"
cp -r ~/.config/{k*,plasma*} "$BACKUP_DIR/" 2>/dev/null
cp -r ~/.local/share/plasma "$BACKUP_DIR/" 2>/dev/null
tar czf "$BACKUP_DIR.tar.gz" "$BACKUP_DIR"
rm -rf "$BACKUP_DIR"
# Keep only last 4 backups
cd ~/.kde-backups && ls -t | tail -n +5 | xargs rm -f
EOF

chmod +x ~/.local/bin/backup-kde.sh
```

## Notes

- KDE 5 uses `kf5` directory structure, KDE 6 uses `kf6`
- Plasma 6 may have different config locations
- Don't backup cache files (*.lock, cache directories)
- KWallet passwords require the same user password to decrypt
- Some configs are machine-specific (display settings)
- Consider using Konsave (KDE settings manager) for easy backups
- Large data folders (Akonadi, Baloo index) can be skipped for config backups