1# Upgrading from older maddy versions23It is generally possible to just install latest version (e.g. using build.sh4script) over the existing installation.56It is recommended to backup state directory (usually /var/lib/maddy for Linux)7before doing so. The new server version may automatically convert DB files in a8way that will make them unreadable by older versions.910Specific instructions for upgrading between versions with incompatible changes11are documented on this page below.1213## Incompatible version migration1415## 0.2 -> 0.316170.3 includes a significant change to the authentication code that makes it18completely independent of IMAP index. This means 0.2 "unified" database cannot19be used in 0.3 and auto-migration is not possible. Additionally, the way20passwords are hashed is changed, meaning that after migration passwords will21need to be reset.2223**Migration utility is SQLite-specific, if you need one that works for24Postgres - reach out at the IRC channel.**25261. Make sure the server is not running.2728```29systemctl stop maddy30```31322. Take a backup of `imapsql.db*` files in state directory (/var/lib/maddy).3334```35mkdir backup36cp /var/lib/maddy/imapsql.db* backup/37```38393. Compile migration utility:4041```42git clone https://github.com/foxcpp/maddy.git43cd maddy/44git checkout v0.3.045cd cmd/migrate-db-0.246go build47```48494. Run compiled binary:5051```52./migrate-db-0.2 /var/lib/maddy/imapsql.db53```54555. Open maddy.conf and make following changes:5657Remove `local_authdb` name from imapsql configuration block:58```59imapsql local_mailboxes {60 driver sqlite361 dsn imapsql.db62}63```6465Add `local_authdb` configuration block using `pass_table` module:6667```68pass_table local_authdb {69 table sql_table {70 driver sqlite371 dsn credentials.db72 table_name passwords73 }74}75```76776. Use `maddy creds create ACCOUNT_NAME` to add credentials to `pass_table`78 store.79807. Start the server back.8182```83systemctl start maddy84```8586## 0.1 -> 0.287880.2 requires several changes in configuration file.8990Change91```92sql local_mailboxes local_authdb {93```94to95```96imapsql local_mailboxes local_authdb {97```9899Replace100```101replace_rcpt postmaster postmaster@$(primary_domain)102```103with104```105replace_rcpt static {106 entry postmaster postmaster@$(primary_domain)107}108```109and110111```112replace_rcpt "(.+)\+(.+)@(.+)" "$1@$3"113```114with115```116replace_rcpt regexp "(.+)\+(.+)@(.+)" "$1@$3"117```