Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Auto-backup on the phone goes into Documents/openGym and keeps the newest 14 (#161)

Duarte Santosee5fdd73c7e3
diff --git a/docs/MOBILE.md b/docs/MOBILE.md
index ed5854c06..cc6f26ae7 100644
--- a/docs/MOBILE.md
+++ b/docs/MOBILE.md
@@ -78,10 +78,14 @@ Where the phone keeps things, in case you ever need them by hand:
belongs to: a paired phone only ever takes the file back for that account.
- `opengym-stash.json`, same directory — changes kept by "Disconnect anyway" or by another
account pairing, waiting for their server and account.
-- `Documents/opengym-backup-YYYY-MM-DD.json` — only with Settings → **Auto-backup on
- changes** switched on: a dated copy after every finished workout or edited routine, in the
- phone's Documents folder where a file manager or a sync app can reach it. Settings →
- **Import backup** reads it back.
+- `Documents/openGym/opengym-backup-YYYY-MM-DD.json` — only with Settings → **Auto-backup on
+ changes** switched on: a dated copy after every finished workout or edited routine, in a
+ folder of its own under the phone's Documents folder, where a file manager or a sync app
+ (Syncthing, a cloud folder) can reach it without taking the rest of Documents along. One
+ file per day; each new copy deletes all but the newest 14 of these dated files in that
+ folder. Nothing else is deleted, in that folder or anywhere: other files you keep there, and
+ the copies versions before 1.3.9 wrote straight into `Documents/`, stay until you remove
+ them yourself. Settings → **Import backup** reads any of them back, wherever it is.
## Prerequisites
diff --git a/frontend/src/lib/mobile.autobackup.test.js b/frontend/src/lib/mobile.autobackup.test.js
new file mode 100644
index 000000000..e849a8024
--- /dev/null
+++ b/frontend/src/lib/mobile.autobackup.test.js
@@ -0,0 +1,116 @@
+// Auto-backup on the phone (#161): the copies go into Documents/openGym/, and each write keeps
+// the newest fourteen there. Nothing outside that folder, and nothing but the app's own dated
+// backups inside it, is ever deleted.
+import { describe, it, expect, beforeEach, vi } from 'vitest'
+import { todayISO } from './format.js'
+
+const h = vi.hoisted(() => ({ files: new Map(), refuseWrite: false, refuseList: false, stuck: new Set(), deleted: [] }))
+
+vi.mock('@capacitor/filesystem', () => ({
+ Directory: { Data: 'DATA', Documents: 'DOCUMENTS', Cache: 'CACHE' },
+ Encoding: { UTF8: 'utf8' },
+ Filesystem: {
+ writeFile: async ({ path, directory, data }) => {
+ if (h.refuseWrite) throw new Error('No space left on device')
+ h.files.set(directory + '/' + path, data)
+ return { uri: 'file://' + path }
+ },
+ readdir: async ({ path, directory }) => {
+ if (h.refuseList) throw new Error('Permission denied')
+ const prefix = directory + '/' + (path ? path + '/' : '')
+ const names = new Map()
+ for (const k of h.files.keys()) {
+ if (!k.startsWith(prefix)) continue
+ const rest = k.slice(prefix.length)
+ const [first, ...more] = rest.split('/')
+ names.set(first, more.length ? 'directory' : 'file')
+ }
+ return { files: [...names].map(([name, type]) => ({ name, type, size: 1, uri: 'file://' + name })) }
+ },
+ deleteFile: async ({ path, directory }) => {
+ if (h.stuck.has(path)) throw new Error('EBUSY')
+ h.deleted.push(path)
+ h.files.delete(directory + '/' + path)
+ },
+ },
+}))
+
+const { writeAutoBackup, AUTO_BACKUP_DIR, AUTO_BACKUP_KEEP } = await import('./mobile.js')
+
+const day = n => { const d = new Date(2026, 0, 1); d.setDate(d.getDate() + n); return d.toISOString().slice(0, 10) }
+const backup = d => 'opengym-backup-' + d + '.json'
+const inFolder = () => [...h.files.keys()].filter(k => k.startsWith('DOCUMENTS/openGym/')).map(k => k.slice('DOCUMENTS/openGym/'.length)).sort()
+const put = (path, data = '{}') => h.files.set('DOCUMENTS/' + path, data)
+
+beforeEach(() => {
+ h.files.clear(); h.deleted.length = 0; h.stuck.clear()
+ h.refuseWrite = false; h.refuseList = false
+})
+
+describe('writeAutoBackup', () => {
+ it('writes today\'s copy into Documents/openGym, not the Documents root', async () => {
+ await writeAutoBackup({ workouts: [{ id: 'w1' }] })
+ expect(AUTO_BACKUP_DIR).toBe('openGym')
+ expect(JSON.parse(h.files.get('DOCUMENTS/openGym/' + backup(todayISO())))).toEqual({ workouts: [{ id: 'w1' }] })
+ expect(h.files.has('DOCUMENTS/' + backup(todayISO()))).toBe(false)
+ })
+
+ it('keeps the newest fourteen in the folder, today\'s among them, and deletes only older dated backups', async () => {
+ for (let i = 0; i < 20; i++) put('openGym/' + backup(day(i)))
+ put('openGym/notes.txt'); put('openGym/opengym-backup-latest.json'); put('openGym/' + backup(day(0)).replace('.json', '.json.bak'))
+ put('openGym/' + backup('2020-01-01') + '/inside.json') // a directory that happens to carry the name
+ await writeAutoBackup({})
+ const dated = inFolder().filter(n => /^opengym-backup-\d{4}-\d{2}-\d{2}\.json$/.test(n))
+ expect(AUTO_BACKUP_KEEP).toBe(14)
+ expect(dated).toHaveLength(14)
+ expect(dated).toContain(backup(todayISO()))
+ // The thirteen newest of the old ones survive next to today's.
+ expect(dated.filter(n => n !== backup(todayISO()))).toEqual([...Array(13)].map((_, i) => backup(day(19 - i))).sort())
+ // Everything that is not an automatic backup is untouched.
+ expect(inFolder()).toEqual(expect.arrayContaining(['notes.txt', 'opengym-backup-latest.json', backup(day(0)).replace('.json', '.json.bak')]))
+ expect(h.files.has('DOCUMENTS/openGym/' + backup('2020-01-01') + '/inside.json')).toBe(true)
+ })
+
+ it('never touches the Documents root, where older versions wrote and where a manual export may sit', async () => {
+ for (let i = 0; i < 30; i++) put(backup(day(i)))
+ put('holiday.pdf')
+ await writeAutoBackup({})
+ expect(h.deleted).toEqual([])
+ expect([...h.files.keys()].filter(k => /^DOCUMENTS\/[^/]+$/.test(k))).toHaveLength(31)
+ })
+
+ it('keeps the copy it just wrote even when a clock set back makes it the oldest', async () => {
+ for (let i = 0; i < 20; i++) put('openGym/' + backup('2099-01-' + String(i + 1).padStart(2, '0')))
+ await writeAutoBackup({})
+ const left = inFolder()
+ expect(left).toHaveLength(14)
+ expect(left).toContain(backup(todayISO()))
+ })
+
+ it('a failed write deletes nothing, and a folder it cannot list or a stuck file stops nothing else', async () => {
+ for (let i = 0; i < 20; i++) put('openGym/' + backup(day(i)))
+ h.refuseWrite = true
+ await writeAutoBackup({})
+ expect(h.deleted).toEqual([])
+
+ h.refuseWrite = false; h.refuseList = true
+ await expect(writeAutoBackup({})).resolves.toBeUndefined()
+ expect(h.files.has('DOCUMENTS/openGym/' + backup(todayISO()))).toBe(true)
+ expect(h.deleted).toEqual([])
+
+ h.refuseList = false
+ h.stuck.add('openGym/' + backup(day(0)))
+ await writeAutoBackup({})
+ expect(inFolder()).toHaveLength(15) // fourteen, plus the one that would not go
+ expect(inFolder()).toContain(backup(day(0)))
+ })
+})
+
+// Settings writes the count out in its subtitle rather than importing it (its tests mock this
+// module wholesale), so the two are pinned together here.
+it('the Settings subtitle names the same number of copies the pruning keeps', async () => {
+ const fs = await import('node:fs')
+ const src = fs.readFileSync(new URL('../views/Settings.jsx', import.meta.url), 'utf8')
+ const m = src.match(/keeps the newest \{0\}[^']*', (\d+)\)/)
+ expect(m && Number(m[1])).toBe(AUTO_BACKUP_KEEP)
+})
diff --git a/frontend/src/lib/mobile.js b/frontend/src/lib/mobile.js
index 62d875488..790709569 100644
--- a/frontend/src/lib/mobile.js
+++ b/frontend/src/lib/mobile.js
@@ -194,19 +194,54 @@ export async function printHtml(html, name) {
await Print.printHtml({ html, name })
}
-// "Auto-backup on changes" (Settings): a dated snapshot dropped into the Documents folder —
+// "Auto-backup on changes" (Settings): a dated snapshot dropped into Documents/openGym/ —
// visible in Files (iOS) / a file manager (Android), unlike the private mirror nativeSave keeps
// — so whatever the user points at that folder (a sync app, a manual copy) always has something
// recent. One file per day; later triggers the same day just overwrite it.
+//
+// The folder is ours alone (#161): until v1.3.9 the files landed in the Documents root, so a
+// sync app pointed at them had to carry the whole Documents folder along, and a year of daily
+// copies piled up there. Now each write keeps only the newest AUTO_BACKUP_KEEP in the folder.
+// The root is never pruned: a manual export saved there carries the same name, and nothing
+// tells it apart from an old automatic copy, so those stay for the person to clear (Import
+// backup still reads either kind).
+export const AUTO_BACKUP_DIR = 'openGym'
+export const AUTO_BACKUP_KEEP = 14
+// Only the exact name writeAutoBackup gives its files is ever pruned; anything else someone
+// keeps in the folder is theirs.
+const AUTO_BACKUP_NAME = /^opengym-backup-\d{4}-\d{2}-\d{2}\.json$/
+
export async function writeAutoBackup(state) {
+ const name = `opengym-backup-${todayISO()}.json`
+ let fs
try {
- const { Filesystem, Directory, Encoding } = await import('@capacitor/filesystem')
- await Filesystem.writeFile({
- path: `opengym-backup-${todayISO()}.json`,
- directory: Directory.Documents,
+ fs = await import('@capacitor/filesystem')
+ await fs.Filesystem.writeFile({
+ path: `${AUTO_BACKUP_DIR}/${name}`,
+ directory: fs.Directory.Documents,
data: JSON.stringify(state),
- encoding: Encoding.UTF8,
+ encoding: fs.Encoding.UTF8,
recursive: true,
})
- } catch (e) { /* best effort — the private mirror in Directory.Data still has the data */ }
+ } catch (e) { return } // best effort — the private mirror in Directory.Data still has the data
+ // Pruning waits for a successful write: a full disk must never cost the copies already there.
+ await pruneAutoBackups(fs, name)
+}
+
+async function pruneAutoBackups({ Filesystem, Directory }, written) {
+ let files
+ try { files = (await Filesystem.readdir({ path: AUTO_BACKUP_DIR, directory: Directory.Documents })).files || [] } catch (e) { return }
+ const older = files
+ // Capacitor before 4 listed bare names; since then an object that also says what it is.
+ .filter(f => typeof f === 'string' || f?.type !== 'directory')
+ .map(f => (typeof f === 'string' ? f : f?.name))
+ // The copy just written is never a candidate, even if a clock set back makes it sort
+ // below the others: it is one of the AUTO_BACKUP_KEEP whatever its date says.
+ .filter(n => AUTO_BACKUP_NAME.test(n || '') && n !== written)
+ // Newest first by the date in the name, which a sync app or a copy cannot disturb the way
+ // it can a modification time.
+ .sort().reverse()
+ for (const n of older.slice(AUTO_BACKUP_KEEP - 1)) {
+ try { await Filesystem.deleteFile({ path: `${AUTO_BACKUP_DIR}/${n}`, directory: Directory.Documents }) } catch (e) { /* one stuck file does not stop the rest */ }
+ }
}
\ No newline at end of file
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index d736fc60a..32d2c3246 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -348,7 +348,7 @@ export default {
'Export backup (JSON)': 'Backup exportieren (JSON)',
'Import backup': 'Backup importieren',
'Auto-backup on changes': 'Automatische Sicherung bei Änderungen',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'Speichert nach jedem beendeten Training oder jeder bearbeiteten Routine eine datierte Kopie im Ordner „Dokumente" — richte eine Sync-App darauf aus oder kopiere die Datei von Hand.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'Speichert nach jedem beendeten Training oder jeder bearbeiteten Routine eine datierte Kopie im Ordner „Dokumente/openGym“ und behält die neuesten {0} — richte eine Sync-App auf diesen Ordner aus oder kopiere die Datei von Hand.',
'Reset everything?': 'Alles zurücksetzen?',
'Reset everything': 'Alles zurücksetzen',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Löscht Plan, Trainings und Körpergewicht auf diesem Gerät. Das kann nicht rückgängig gemacht werden.',
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index 5764277a7..dc3c3c90b 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': 'Exportar copia (JSON)',
'Import backup': 'Importar copia',
'Auto-backup on changes': 'Copia automática al modificar',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'Guarda una copia fechada en la carpeta Documentos al terminar un entrenamiento o editar una rutina — apunta una app de sincronización a esa carpeta, o copia el archivo a mano.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'Guarda una copia fechada en la carpeta Documentos/openGym al terminar un entrenamiento o editar una rutina, y conserva las {0} más recientes — apunta una app de sincronización a esa carpeta, o copia el archivo a mano.',
'Reset everything?': '¿Restablecer todo?',
'Reset everything': 'Restablecer todo',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Elimina tu plan, entrenamientos y peso corporal en este dispositivo. No se puede deshacer.',
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 277c4dbc0..3f46498a1 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': 'Exporter une sauvegarde (JSON)',
'Import backup': 'Importer une sauvegarde',
'Auto-backup on changes': 'Sauvegarde automatique',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'Enregistre une copie datée dans le dossier Documents après chaque entraînement terminé ou modification de routine — pointez une appli de synchronisation dessus, ou copiez le fichier à la main.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'Enregistre une copie datée dans le dossier Documents/openGym après chaque entraînement terminé ou modification de routine, et garde les {0} plus récentes — pointez une appli de synchronisation sur ce dossier, ou copiez le fichier à la main.',
'Reset everything?': 'Tout réinitialiser ?',
'Reset everything': 'Tout réinitialiser',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Supprime ton plan, tes séances et ton poids corporel sur cet appareil. Irréversible.',
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 303289210..7224b5c82 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': 'बैकअप निर्यात करें (JSON)',
'Import backup': 'बैकअप आयात करें',
'Auto-backup on changes': 'बदलाव पर ऑटो-बैकअप',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'वर्कआउट खत्म करने या रूटीन एडिट करने के बाद Documents फ़ोल्डर में तारीख़ वाली कॉपी सेव करता है — उस फ़ोल्डर पर कोई सिंक ऐप लगाएं, या फ़ाइल को हाथ से कॉपी करें।',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'वर्कआउट खत्म करने या रूटीन एडिट करने के बाद Documents/openGym फ़ोल्डर में तारीख़ वाली कॉपी सेव करता है और सबसे नई {0} कॉपी रखता है — उस फ़ोल्डर पर कोई सिंक ऐप लगाएं, या फ़ाइल को हाथ से कॉपी करें।',
'Reset everything?': 'सब कुछ रीसेट करें?',
'Reset everything': 'सब कुछ रीसेट करें',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'इस डिवाइस पर आपकी योजना, वर्कआउट और वज़न हट जाएँगे। इसे पूर्ववत नहीं किया जा सकता।',
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 28c1a24a8..acf40c392 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -333,7 +333,7 @@ export default {
'Data': 'Adatok',
'Export backup (JSON)': 'Biztonsági mentés exportálása (JSON)',
'Import backup': 'Biztonsági mentés importálása',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'Dátumozott másolatot ment a Dokumentumok mappába egy edzés befejezése vagy egy rutin szerkesztése után — irányíts rá egy szinkronizáló appot, vagy másold ki kézzel.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'Dátumozott másolatot ment a Dokumentumok/openGym mappába egy edzés befejezése vagy egy rutin szerkesztése után, és a legutóbbi {0} másolatot tartja meg — irányíts erre a mappára egy szinkronizáló appot, vagy másold ki kézzel.',
'Auto-backup on changes': 'Automatikus mentés módosításkor',
'Reset everything?': 'Mindent visszaállítasz?',
'Reset everything': 'Minden visszaállítása',
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 65fbe048b..7d0102c2d 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': 'Esporta backup (JSON)',
'Import backup': 'Importa backup',
'Auto-backup on changes': 'Backup automatico alle modifiche',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': "Salva una copia datata nella cartella Documenti dopo aver terminato un allenamento o modificato una routine — punta un'app di sincronizzazione lì, oppure copia il file a mano.",
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': "Salva una copia datata nella cartella Documenti/openGym dopo aver terminato un allenamento o modificato una routine, e tiene le {0} più recenti — punta un'app di sincronizzazione su quella cartella, oppure copia il file a mano.",
'Reset everything?': 'Azzerare tutto?',
'Reset everything': 'Azzera tutto',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Elimina piano, allenamenti e peso corporeo su questo dispositivo. Irreversibile.',
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 9018a95d3..639191aeb 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': '백업 내보내기 (JSON)',
'Import backup': '백업 가져오기',
'Auto-backup on changes': '변경 시 자동 백업',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': '운동을 마치거나 루틴을 수정한 뒤 날짜가 적힌 사본을 문서 폴더에 저장합니다 — 동기화 앱이 그 폴더를 보게 하거나 파일을 직접 복사하세요.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': '운동을 마치거나 루틴을 수정한 뒤 날짜가 적힌 사본을 문서/openGym 폴더에 저장하고 최근 {0}개만 남깁니다 — 동기화 앱이 그 폴더를 보게 하거나 파일을 직접 복사하세요.',
'Reset everything?': '전부 초기화할까요?',
'Reset everything': '전부 초기화',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': '이 기기의 계획, 운동, 체중을 삭제합니다. 되돌릴 수 없어요.',
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 668ec24b2..3484d0ed2 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': 'Eksportuj kopię (JSON)',
'Import backup': 'Importuj kopię',
'Auto-backup on changes': 'Automatyczna kopia przy zmianach',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'Zapisuje datowaną kopię w folderze Dokumenty po zakończeniu treningu lub edycji rutyny — wskaż na ten folder aplikację synchronizującą albo skopiuj plik ręcznie.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'Zapisuje datowaną kopię w folderze Dokumenty/openGym po zakończeniu treningu lub edycji rutyny i zachowuje {0} najnowszych — wskaż ten folder aplikacji synchronizującej albo skopiuj plik ręcznie.',
'Reset everything?': 'Zresetować wszystko?',
'Reset everything': 'Zresetuj wszystko',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Usuwa plan, treningi i masę ciała na tym urządzeniu. Nie można tego cofnąć.',
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 54b70d992..0ca0b9917 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -330,7 +330,7 @@ export const PT_BR_OVERRIDES = {
// --- drop-sets, auto-backup and server pairing ---
'Auto-backup on changes': 'Backup automático ao alterar',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'Salva uma cópia datada na pasta Documentos depois de terminar um treino ou editar uma rotina — aponte um aplicativo de sincronização para ela, ou copie o arquivo na mão.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'Salva uma cópia datada na pasta Documentos/openGym depois de terminar um treino ou editar uma rotina e mantém as {0} mais recentes — aponte um aplicativo de sincronização para essa pasta, ou copie o arquivo na mão.',
'Disconnect': 'Desconectar',
'Disconnect from your server?': 'Desconectar do seu servidor?',
'Disconnected — back to local-only': 'Desconectado — de volta ao modo somente local',
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index fb5d3ef38..1066f2628 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': 'Exportar cópia (JSON)',
'Import backup': 'Importar cópia',
'Auto-backup on changes': 'Cópia automática ao alterar',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'Guarda uma cópia datada na pasta Documentos após terminar um treino ou editar uma rotina — aponta uma app de sincronização para lá, ou copia o ficheiro à mão.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'Guarda uma cópia datada na pasta Documentos/openGym após terminar um treino ou editar uma rotina e mantém as {0} mais recentes — aponta uma app de sincronização para essa pasta, ou copia o ficheiro à mão.',
'Reset everything?': 'Repor tudo?',
'Reset everything': 'Repor tudo',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Elimina o teu plano, treinos e peso corporal neste dispositivo. Não pode ser anulado.',
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 9bfac9658..b70e25ed6 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': 'Экспорт резервной копии (JSON)',
'Import backup': 'Импорт резервной копии',
'Auto-backup on changes': 'Автосохранение копии при изменениях',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'Сохраняет копию с датой в папку «Документы» после завершения тренировки или редактирования программы — направьте туда приложение синхронизации или скопируйте файл вручную.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'Сохраняет копию с датой в папку «Документы/openGym» после завершения тренировки или редактирования программы и хранит {0} последних — направьте на эту папку приложение синхронизации или скопируйте файл вручную.',
'Reset everything?': 'Сбросить всё?',
'Reset everything': 'Сбросить всё',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Удаляет план, тренировки и вес тела на этом устройстве. Отменить нельзя.',
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 952e70287..fc9c869d3 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -334,7 +334,7 @@ export default {
'Export backup (JSON)': 'ส่งออกข้อมูลสำรอง (JSON)',
'Import backup': 'นำเข้าข้อมูลสำรอง',
'Auto-backup on changes': 'สำรองข้อมูลอัตโนมัติเมื่อมีการเปลี่ยนแปลง',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'บันทึกสำเนาที่มีวันที่กำกับไว้ในโฟลเดอร์ Documents หลังจบการออกกำลังกายหรือแก้ไขรูทีน — ตั้งแอปซิงก์ให้ชี้มาที่นี่ หรือคัดลอกออกไปเองก็ได้',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'บันทึกสำเนาที่มีวันที่กำกับไว้ในโฟลเดอร์ Documents/openGym หลังจบการออกกำลังกายหรือแก้ไขรูทีน และเก็บไว้เฉพาะ {0} ฉบับล่าสุด — ตั้งแอปซิงก์ให้ชี้มาที่โฟลเดอร์นี้ หรือคัดลอกออกไปเองก็ได้',
'Reset everything?': 'รีเซ็ตทุกอย่าง?',
'Reset everything': 'รีเซ็ตทุกอย่าง',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'จะลบแผน, การออกกำลังกาย และน้ำหนักตัวบนเครื่องนี้ ไม่สามารถย้อนกลับได้',
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 6f0a9eca2..1272dcd6a 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': 'Yedeği dışa aktar (JSON)',
'Import backup': 'Yedeği içe aktar',
'Auto-backup on changes': 'Değişikliklerde otomatik yedek',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': 'Bir antrenmanı bitirdikten veya bir rutini düzenledikten sonra Belgeler klasörüne tarihli bir kopya kaydeder — bir senkronizasyon uygulamasını o klasöre yönlendir ya da dosyayı elle kopyala.',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': 'Bir antrenmanı bitirdikten veya bir rutini düzenledikten sonra Belgeler/openGym klasörüne tarihli bir kopya kaydeder ve en yeni {0} kopyayı tutar — bir senkronizasyon uygulamasını bu klasöre yönlendir ya da dosyayı elle kopyala.',
'Reset everything?': 'Her şey sıfırlansın mı?',
'Reset everything': 'Her şeyi sıfırla',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': 'Bu cihazdaki planını, antrenmanlarını ve vücut ağırlığını siler. Geri alınamaz.',
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 5ad7f7998..ff1605287 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -333,7 +333,7 @@ export default {
'Export backup (JSON)': '导出备份(JSON)',
'Import backup': '导入备份',
'Auto-backup on changes': '变更时自动备份',
- 'Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.': '完成训练或编辑计划后,会在「文档」文件夹中保存一份带日期的副本——可以让同步应用指向该文件夹,或手动复制出来。',
+ 'Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.': '完成训练或编辑计划后,会在「文档/openGym」文件夹中保存一份带日期的副本,并只保留最近的 {0} 份——可以让同步应用指向该文件夹,或手动复制出来。',
'Reset everything?': '重置所有内容?',
'Reset everything': '重置所有内容',
'Deletes your plan, workouts and body weight on this device. This cannot be undone.': '删除本设备上的计划、训练和体重。无法撤销。',
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index a82efcf33..e2c48b19a 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -418,8 +418,10 @@ export default function Settings() {
accessory="chevron" onClick={importFromHevy} />
<Row icon="upload" iconTint="var(--blue)" title={t('Import backup')} accessory="chevron" onClick={() => fileRef.current.click()} />
<Row icon="download" iconTint="var(--blue)" title={t('Export backup (JSON)')} accessory="chevron" onClick={doExport} />
+ {/* 14 is AUTO_BACKUP_KEEP in lib/mobile.js, written out because the Settings tests mock
+ that module wholesale; mobile.autobackup.test.js pins the two together. */}
{MOBILE && <Row icon="history" iconTint="var(--blue)" title={t('Auto-backup on changes')}
- subtitle={t('Saves a dated copy to the Documents folder after finishing a workout or editing a routine — point a sync app at it, or copy it out by hand.')}>
+ subtitle={t('Saves a dated copy to Documents/openGym after finishing a workout or editing a routine, and keeps the newest {0} — point a sync app at that folder, or copy it out by hand.', 14)}>
<Switch checked={!!S.autoBackup} onChange={v => update(s => { s.autoBackup = v })} />
</Row>}
<Row icon="trash" iconTint="var(--red)" title={t('Reset everything')} danger onClick={resetEverything} />