cli + tui to publish to leaflet (wip) & manage tasks, notes & watch/read lists 馃崈
charm leaflet readability golang
at main 297 lines 5.0 kB view raw view rendered
1--- 2title: Import and Export 3sidebar_label: Import & Export 4sidebar_position: 1 5description: Data portability, backups, and migration. 6--- 7 8# Import and Export 9 10Noteleaf stores data in open formats for portability: SQLite for structured data and Markdown for notes. 11 12## Data Storage 13 14### SQLite Database 15 16Location varies by platform: 17 18**macOS:** 19 20``` 21~/Library/Application Support/noteleaf/noteleaf.db 22``` 23 24**Linux:** 25 26``` 27~/.local/share/noteleaf/noteleaf.db 28``` 29 30**Windows:** 31 32``` 33%LOCALAPPDATA%\noteleaf\noteleaf.db 34``` 35 36### Markdown Files 37 38Notes are stored as individual markdown files: 39 40**Default location:** 41 42``` 43<data_dir>/notes/ 44``` 45 46Configure via `notes_dir` in `.noteleaf.conf.toml`. 47 48### Articles 49 50Saved articles are stored as markdown: 51 52**Default location:** 53 54``` 55<data_dir>/articles/ 56``` 57 58Configure via `articles_dir` in `.noteleaf.conf.toml`. 59 60## JSON Export 61 62### Task Export 63 64Export tasks to JSON format: 65 66```sh 67noteleaf todo view 123 --json 68noteleaf todo list --static --json 69``` 70 71Output includes all task attributes: 72 73- Description 74- Status, priority 75- Project, context, tags 76- Due dates, recurrence 77- Dependencies, parent tasks 78- Timestamps 79 80### Export Format Configuration 81 82Set default export format: 83 84```sh 85noteleaf config set export_format "json" 86``` 87 88Options: 89 90- `json` (default) 91- `csv` (planned) 92- `markdown` (planned) 93 94## Backup Strategy 95 96### Full Backup 97 98Back up the entire data directory: 99 100```sh 101# macOS 102cp -r ~/Library/Application\ Support/noteleaf ~/Backups/noteleaf-$(date +%Y%m%d) 103 104# Linux 105cp -r ~/.local/share/noteleaf ~/backups/noteleaf-$(date +%Y%m%d) 106``` 107 108Includes: 109 110- SQLite database 111- Notes directory 112- Articles directory 113- Configuration file 114 115### Database Only 116 117```sh 118# macOS 119cp ~/Library/Application\ Support/noteleaf/noteleaf.db ~/Backups/ 120 121# Linux 122cp ~/.local/share/noteleaf/noteleaf.db ~/backups/ 123``` 124 125### Notes Only 126 127```sh 128# Copy notes directory 129cp -r <data_dir>/notes ~/Backups/notes-$(date +%Y%m%d) 130``` 131 132Notes are plain markdown files, easily versioned with Git: 133 134```sh 135cd <data_dir>/notes 136git init 137git add . 138git commit -m "Initial notes backup" 139``` 140 141## Restore from Backup 142 143### Full Restore 144 145```sh 146# Stop noteleaf 147# Replace data directory 148cp -r ~/Backups/noteleaf-20240315 ~/Library/Application\ Support/noteleaf 149``` 150 151### Database Restore 152 153```sh 154cp ~/Backups/noteleaf.db ~/Library/Application\ Support/noteleaf/ 155``` 156 157### Notes Restore 158 159```sh 160cp -r ~/Backups/notes-20240315 <data_dir>/notes 161``` 162 163## Direct Database Access 164 165SQLite database is accessible with standard tools: 166 167```sh 168# Open database 169sqlite3 ~/Library/Application\ Support/noteleaf/noteleaf.db 170 171# List tables 172.tables 173 174# Query tasks 175SELECT id, description, status FROM tasks WHERE status = 'pending'; 176 177# Export to CSV 178.mode csv 179.output tasks.csv 180SELECT * FROM tasks; 181.quit 182``` 183 184## Portable Installation 185 186Use environment variables for portable setup: 187 188```sh 189export NOTELEAF_DATA_DIR=/path/to/usb/noteleaf-data 190export NOTELEAF_CONFIG=/path/to/usb/noteleaf.conf.toml 191noteleaf todo list 192``` 193 194Useful for: 195 196- USB drive installations 197- Synced folders (Dropbox, iCloud) 198- Multiple workspaces 199- Testing environments 200 201## Migration Strategies 202 203### From TaskWarrior 204 205Manual migration via SQLite: 206 2071. Export TaskWarrior data to JSON 2082. Parse JSON and insert into noteleaf database 2093. Map TaskWarrior attributes to Noteleaf schema 210 211Custom migration script required (future documentation). 212 213### From todo.txt 214 215Convert todo.txt to Noteleaf tasks: 216 2171. Parse todo.txt format 2182. Map projects, contexts, priorities 2193. Bulk insert via SQLite 220 221Custom migration script required (future documentation). 222 223### From Other Note Apps 224 225Notes are markdown files: 226 2271. Export notes from source app 2282. Convert to plain markdown 2293. Copy to `<data_dir>/notes/` 2304. Noteleaf will index them on next scan 231 232## Sync and Cloud Storage 233 234### Cloud Sync 235 236Store data directory in synced folder: 237 238```sh 239# Use Dropbox 240export NOTELEAF_DATA_DIR=~/Dropbox/noteleaf-data 241 242# Use iCloud 243export NOTELEAF_DATA_DIR=~/Library/Mobile\ Documents/com~apple~CloudDocs/noteleaf 244``` 245 246**Warning:** SQLite databases don't handle concurrent writes well. Only run one Noteleaf instance at a time per database. 247 248### Version Control 249 250Notes directory can be versioned: 251 252```sh 253cd <data_dir>/notes 254git init 255git add . 256git commit -m "Initial commit" 257git remote add origin <repository-url> 258git push -u origin main 259``` 260 261Automatic git commits planned for future release. 262 263## Data Formats 264 265### SQLite Schema 266 267View schema: 268 269```sh 270sqlite3 noteleaf.db .schema 271``` 272 273Tables include: 274 275- `tasks` - Task management 276- `notes` - Note metadata 277- `articles` - Article metadata 278- `books`, `movies`, `tv_shows` - Media tracking 279- `publications` - Leaflet.pub publications 280- Linking tables for tags, dependencies 281 282### Markdown Format 283 284Notes use standard markdown with YAML frontmatter: 285 286```markdown 287--- 288title: Note Title 289created: 2024-03-15T10:30:00Z 290modified: 2024-03-15T11:00:00Z 291tags: [tag1, tag2] 292--- 293 294# Note Content 295 296Regular markdown content... 297```