Publishing & Importing Instances
macpine provides a powerful way to package, share, and restore virtual machines using the publish and import commands. This is useful for creating backups, sharing development environments, or distributing pre-configured appliances.
Publishing an Instance
The alpine publish command creates a .tar.gz archive of a specified instance. This archive contains the VM's disk image and its configuration file.
alpine publish my-instance
This will create a file named my-instance.tar.gz in your current directory.
If the instance is running, macpine will attempt to sync the filesystem and gracefully stop it before publishing to ensure data consistency. It will then restart the instance after the archive is created.
Encrypting Archives
For secure distribution or backup, you can encrypt the archive with a passphrase using the -e or --encrypt flag. macpine uses the modern and secure age encryption tool.
alpine publish --encrypt my-secure-instance
You will be prompted to enter and confirm a passphrase. If you leave it blank, a strong, random passphrase will be generated for you.
Enter passphrase (leave empty to autogenerate a secure one):
age: using autogenerated passphrase "better-avocado-regret-marriage..."
This command will produce an encrypted my-secure-instance.tar.gz.age file.
Importing an Instance
The alpine import command restores an instance from an archive. The new instance will be named after the archive file (e.g., my-instance.tar.gz becomes an instance named my-instance).
Standard Import
# Ensure no instance with the same name exists
alpine delete my-instance
# Import from the archive
alpine import my-instance.tar.gz
Encrypted Import
If you are importing an .age-encrypted file, macpine will prompt you for the passphrase.
alpine import my-secure-instance.tar.gz.age
Enter passphrase: <your-passphrase-here>
Importing from a URL
You can also import an instance directly from a URL. macpine will download the archive before importing it.
alpine import https://example.com/shared-instance.tar.gz
This feature makes it easy to share and distribute macpine environments.