bgamari / trac-to-remarkup

Moved to GitLab: https://gitlab.haskell.org/bgamari/trac-to-remarkup
https://gitlab.haskell.org
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Usage

note: This requires a patched GitLab installation.

Test import preparation

  1. Reset GitLab database

    In the case of NixOS:

    sudo systemctl stop gitlab
    sudo systemctl stop gitlab-workhorse
    sudo systemctl stop gitlab-sidekiq
    sudo systemctl stop gitaly
    echo 'DROP DATABASE gitlab; DROP ROLE gitlab;' | sudo -u postgres psql 
    sudo rm -Rf /var/gitlab/state
    sudo systemd-tmpfiles --create
    sudo systemctl start gitlab
    sudo systemctl start gitlab-workhorse
    sudo systemctl start gitlab-sidekiq
    sudo systemctl start gitaly
    # for post-import ticket fix-up
    sudo -u postgres psql gitlab -c 'GRANT SELECT, INSERT, UPDATE ON TABLE issues TO ben;'
  2. Restore from backup: sudo gitlab-rake gitlab:backup:restore

  3. Make sure that authorized_keys is up-to-date (this doesn't seem to happen during restore):

    sudo systemctl stop gitlab
    sudo systemctl stop gitlab-workhorse
    sudo systemctl stop gitlab-sidekiq
    sudo gitlab-rake gitlab:shell:setup
    sudo systemctl start gitlab
    sudo systemctl start gitlab-workhorse
    sudo systemctl start gitlab-sidekiq
  4. Create a ghc group.

  5. Create a ghc project in said group.

  6. Create an administrator account called trac-import

  7. Enable Issue tracker permission

Trac import

  1. Restore Trac backup:
    echo 'DROP DATABASE trac_ghc; CREATE DATABASE trac_ghc;' | sudo -u postgres psql
    xzcat trac_ghc.sql.xz | sudo -u postgres psql trac_ghc
    echo 'GRANT SELECT ON ALL TABLES IN SCHEMA public TO ben;' | sudo -u postgres psql trac_ghc
    cat fixup-trac-db.sql | sudo -u postgres psql trac_ghc
  2. Shut down postfix to ensure no mail makes it out.
  3. Add an SSH key for this user so the import script can push the wiki
  4. Create an access token for this user
  5. Copy Settings.hs.dist into Settings.hs
  6. Set project in Settings.hs to the project ID of the ghc project
  7. Add an access token for root, update gitlabToken in Settings.hs.
  8. Set gitlabBaseUrl in Settings.hs
  9. Adjust other settings in Settings.hs as needed
  10. Build & run it (don't forget to tee the log to a file)
  11. Push ghc/ghc repo
  12. Run create-mirrors.py
  13. Clear the mailers sidekiq queue
  14. Run sudo -u postgres bash diff-ticket-lists.sh to verify that there are no unexpectedly-missing tickets.
  15. Run git push git@gitlab.haskell.org:ghc/ghc origin/master:refs/heads/wip/magic-carpet-ride to trigger reprocessing of issue mentions in commits
  16. Clear the mailers sidekiq queue again before reenabling mail
  17. sudo -u postgres psql gitlab -c 'REVOKE SELECT, INSERT, UPDATE ON TABLE issues FROM ben;'
  18. Run push-labels.py

Wiki Fix-up

git clone git@gitlab.haskell.org:ghc/ghc.wiki.git
cd ghc.wiki
git branch unsquashed
bash ../fix-wiki.sh
python3 ../squash-wiki.py
python3 ../make-index.py
git add index.md
git commit -m 'Add index'
git checkout master
git reset --hard all-squashed
git push origin master unsquashed -f

Final import checklist

  1. Announce beginning of import on ghc-devs@
  2. Redirect gitlab.haskell.org and ghc.haskell.org to placeholders
  3. Grab Trac database export
  4. Run GitLab backup
  5. Disable mail delivery on GitLab
  6. Perform import as described above
  7. Delete mailers queue