Documentation Index
Fetch the complete documentation index at: https://mintlify.com/himansaBro/JungleConfig/llms.txt
Use this file to discover all available pages before exploring further.
JungleConfig.Backup(File path, boolean override) copies the current serialized configuration to a destination file you specify. It returns true when the copy succeeds and false when the destination already exists and override is false. The method is available across all storage modes — file-backed, encrypted, in-memory, and FlatJson — making it a consistent way to snapshot configuration state regardless of how the instance was created.
Override behaviour
Theoverride flag controls what happens when the destination file already exists:
override = false— if the destination file already exists, the method returnsfalseimmediately without writing anything. The existing destination file is left completely untouched. Use this when you want idempotent daily snapshots (one file per day at most) or when losing a previous backup would be unacceptable.override = true— if the destination file exists, it is overwritten with the current configuration contents. The destination path must point to a regular file (not a directory) and the process must have write permission on it.
Creating a new backup file
When the destination file does not exist,NativeIOHandler.Backup calls path.canWrite() before attempting path.createNewFile(). On some JVMs, canWrite() returns false for a path that does not yet exist (even when the parent directory is writable), which causes Backup to throw an IOException with the message "No permission to Write" before the file is ever created. If you encounter this, ensure the parent directory exists and is writable. If canWrite() still returns false on your JVM for a non-existent path, pre-create the file manually before calling Backup.
After the file is created, Backup writes the current serialized contents to it with writeToFile. The parent directory of the destination path must already exist — Backup does not create intermediate directories automatically.
Encrypted backups
When theJungleConfig instance was created with EncryptedConfig, the backup file contains the same Base64-encoded ciphertext that the primary file holds at the moment Backup is called. The backup is fully encrypted with the same password — there is no plaintext copy produced at any point during the backup operation. To read the backup later, open it with EncryptedConfig using the same password.
In-memory and FlatJson modes
Backup is available on all JungleConfig modes. For InMemoryConfig and FlatJsonConfig instances, the current serialized representation of the in-memory store is written to the destination file in its respective format. This means:
- An
InMemoryConfigbackup produces a file in the standard JConfig001 format that can be opened withnew JungleConfig(File). - A
FlatJsonConfigbackup produces a flat JSON file.
