Overview
Plakar allows you to import configurations for stores, sources, and destinations from various sources including files, piped input, and external tools like rclone. This guide explains how to use the import
subcommand for plakar store
, plakar source
, and plakar destination
.
Basic Usage
The import command can read configuration data from:
- Standard input (stdin) - useful for piping from other commands
- A file specified with the
-config
option - URLs (when using
-config
with a URL)
Importing from a Configuration File
Use the -config
option to specify a configuration file to import. Create a YAML file with the appropriate structure for the type of configuration you’re importing.
For example, to import store configurations, create a file like my-stores.yaml
:
1minio:
2 access_key: minioadmin
3 location: s3://localhost:9000/kloset
4 passphrase: superpassphrase
5 secret_access_key: minioadmin
6 use_tls: "false"
Then import it with:
1plakar store import -config my-stores.yaml
Similarly for sources and destinations:
1plakar source import -config my-sources.yaml
2plakar destination import -config my-destinations.yaml
The configuration files should be in YAML format with named sections for each configuration entry.
Importing from Piped Input
You can pipe configuration data directly from other commands:
1# Import a specific source configuration as a destination
2plakar source show | plakar destination import mybucket
3
4# Import all sources as destinations
5plakar source show | plakar destination import
6
7# Import from rclone configuration
8rclone config show | plakar store import -rclone koofr
Command Options
-config
Specifies the file or URL to read configuration from. Without this option, the command reads from stdin.
Examples:
1# Import from a local file
2plakar store import -config /path/to/stores.yaml
3
4# Import from a URL
5plakar store import -config https://example.com/config.yaml
-overwrite
Overwrites existing configuration sections with the same names. Without this option, importing will fail if a section with the same name already exists.
Example:
1plakar store import -config new-stores.yaml -overwrite
-rclone
Treats the input as an rclone configuration file. This allows you to import rclone remotes as Plakar stores.
Example:
1rclone config show | plakar store import -rclone myremote
When using -rclone
, you can specify which rclone remote to import by providing its name as an additional argument.
Section Selection
You can specify which sections to import by listing their names. Sections can be renamed during import by appending :newname
.
Examples:
1# Import only specific sections
2plakar store import -config stores.yaml section1 section2
3
4# Import and rename sections
5plakar store import -config stores.yaml oldname:newname
Configuration File Format
Configuration files should be in YAML format. Each top-level key represents a named configuration section.
Store Configuration Example
1mystorage:
2 location: s3://mybucket
3 access_key: myaccesskey
4 secret_access_key: mysecretkey
5
6localbackup:
7 location: /var/backups
Source Configuration Example
1myapp:
2 location: /var/www/myapp
3 excludes: "*.log,*.tmp"
4
5database:
6 location: postgresql://user:pass@localhost/mydb
Destination Configuration Example
1restorepoint:
2 location: /mnt/restore
3 permissions: 0755
4
5cloudrestore:
6 location: s3://restore-bucket
7 access_key: restorekey
8 secret_access_key: restoresecret
Practical Examples
Migrating from rclone
If you have rclone configurations, you can easily import them as Plakar stores:
1# Show available rclone remotes
2rclone config show
3
4# Import a specific rclone remote as a Plakar store
5rclone config show | plakar store import -rclone myremote
Bulk Configuration Management
You can export and import configurations between different Plakar installations:
1# Export current store configurations
2plakar store show > stores-backup.yaml
3
4# Import on another machine
5plakar store import -config stores-backup.yaml
Converting Sources to Destinations
A common use case is to use the same locations for both backup sources and restore destinations:
1# Import all sources as destinations
2plakar source show | plakar destination import
3
4# Import a specific source as a destination with a new name
5plakar source show | plakar destination import mysource:myrestore
Troubleshooting
Common Issues
Permission Denied: Ensure you have read access to the configuration file and write access to Plakar’s configuration directory.
Invalid YAML: Validate your YAML syntax before importing. Use tools like
yamllint
or online validators.Name Conflicts: Use
-overwrite
to replace existing configurations, or rename sections during import.rclone Import Issues: Ensure rclone is installed and the specified remote exists in your rclone configuration.
Verification
After importing, verify the configuration was imported correctly:
1plakar store show
2plakar source show
3plakar destination show
Use the check
subcommand to validate configurations:
1plakar store check mystore
2plakar source check mysource
3plakar destination check mydest
Related Commands
plakar store
- Manage store configurationsplakar source
- Manage source configurationsplakar destination
- Manage destination configurationsplakar store show
- Display current store configurationsplakar source show
- Display current source configurations