Gabriella439 / Gabriella439/turtle
Full practical example
- Dominant language
- Haskell
- Stars
- 978
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Description
Nothing like a full example to pull all the concepts you just learned together. I give you this code so you can see review the code (and see what mistakes a new user of your library made) and to possibly include for others to learn from.
I know some repositories have a examples subdirectory. This could even fit on a Tutorials.DatabaseBackup example documentation page or something?
code:
``` haskell
{-# LANGUAGE OverloadedStrings #-}
import Control.Category ((<<<), (>>>))
import qualified Control.Foldl as Fold
import Data.Maybe
import Turtle
run sink f = sink (f empty)
main = do
-- backup old db
output "revert.sql" (inproc "mysqldump" ["-uroot", "myproject"] empty)
-- newest filename from server
newestFileName <- fmap fromText . listToMaybe <$>
fold ((inproc "ssh" ["lalala", "ls -Art /backups/db/myproject | tail -n 1"]) empty) Fold.list
let serverName = "lalala"
dbName = "myproject-copy"
backupDir = "/backups/db/myproject/"
newestFileName' = fromMaybe (error "couldn't get backup path") newestFileName
backupFilePath = backupDir newestFileName'
localFilePath = "/tmp/" newestFileName'
backupFilePath' = either (\e -> error $ "Couldn't parse backupFilePath: " <> show e) id (toText backupFilePath)
localFilePath' = either (\e -> error $ "Couldn't parse localFilePath: " <> show e) id (toText localFilePath)
-- download backup
sh $ inproc "rsync" ["-avz", serverName, ":", backupFilePath', localFilePath'] empty
-- drop old db (should have backup)
run sh (inshell ("mysqladmin -uroot drop -f " <> dbName))
-- restore database from just downloaded backup
run sh (inshell ("zcat " <> localFilePath') >>> inshell ("mysql -uroot" <> dbName))
print "done"
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Review the supplied Haskell example first, then inspect the repository's examples area and the Tutorials.DatabaseBackup documentation location mentioned in the issue. Done means the reviewed full backup and restore example is placed in the chosen example or documentation location and is understandable for new Turtle users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, mysql
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100