Maintenance Guide
Last Updated: 2026-02-03 | Reading Time: 10 minutes
Regular maintenance procedures for PasteShelf.
Table of Contents
Section titled “Table of Contents”Routine Maintenance
Section titled “Routine Maintenance”Daily (Automatic)
Section titled “Daily (Automatic)”- Sync status check
- Expired item cleanup
- Search index optimization
Weekly
Section titled “Weekly”- Database vacuum
- Log rotation
- Cache cleanup
Monthly
Section titled “Monthly”- Full backup verification
- Storage usage review
- Performance analysis
Database Maintenance
Section titled “Database Maintenance”CoreData Maintenance
Section titled “CoreData Maintenance”class DatabaseMaintenance { func performMaintenance() async { // 1. Clean up deleted items await cleanupDeletedItems()
// 2. Optimize search index await optimizeSearchIndex()
// 3. Compact database await compactDatabase() }
func cleanupDeletedItems() async { let context = persistenceController.container.newBackgroundContext()
await context.perform { let fetchRequest: NSFetchRequest<NSFetchRequestResult> = ClipboardItem.fetchRequest() fetchRequest.predicate = NSPredicate(format: "isDeleted == YES AND deletedAt < %@", Date().addingTimeInterval(-7 * 24 * 60 * 60) as NSDate)
let deleteRequest = NSBatchDeleteRequest(fetchRequest: fetchRequest) try? context.execute(deleteRequest) } }}SQLite Maintenance
Section titled “SQLite Maintenance”# Manual SQLite optimization (if needed)sqlite3 ~/Library/Application\ Support/PasteShelf/PasteShelf.sqlite "VACUUM;"sqlite3 ~/Library/Application\ Support/PasteShelf/PasteShelf.sqlite "ANALYZE;"Storage Cleanup
Section titled “Storage Cleanup”Cleanup Script
Section titled “Cleanup Script”func cleanupStorage() async { // Remove orphaned files let contentDir = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask) .first!.appendingPathComponent("PasteShelf/Content")
let storedFiles = try? FileManager.default.contentsOfDirectory(at: contentDir, includingPropertiesForKeys: nil) let referencedFiles = await getReferencedFileIds()
for file in storedFiles ?? [] { let fileId = file.deletingPathExtension().lastPathComponent if !referencedFiles.contains(fileId) { try? FileManager.default.removeItem(at: file) } }}Manual Cleanup
Section titled “Manual Cleanup”# Check storage usagedu -sh ~/Library/Application\ Support/PasteShelf/
# Clear cacherm -rf ~/Library/Caches/com.pasteshelf.PasteShelf/Update Procedures
Section titled “Update Procedures”Pre-Update
Section titled “Pre-Update”- Backup clipboard history
- Check system requirements
- Close PasteShelf
Post-Update
Section titled “Post-Update”- Verify license activation
- Check sync status
- Test core functionality
Related Documentation
Section titled “Related Documentation”| Document | Description |
|---|---|
| Monitoring & Logging | System monitoring |
| Troubleshooting | Common issues |
Last updated: 2026-02-03