Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Pack up a project and some couchdb docs
# related to
$uri = "http://localhost:5984/blog__prototype/_all_docs?include_docs=true"
$uri2 = "http://localhost:5984/_users/_design/_auth?include_docs=true"
$uri3 = "http://localhost:5984/requests/_design/new?include_docs=true"
$user = 'user'
$pass = 'password'
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue
Write-Host "Saving backup script ..."
copy .\packup.ps1 .\_bak\packup\
copy .\.gitignore .\_bak\packup\
Write-Host "Dumping couchDB prototype docs, _users/_auth and request/new docs ..."
(Invoke-WebRequest -Uri $uri -Headers $Headers).content > ".\_bak\couchdb\blog_prototype-docs.json"
(Invoke-WebRequest -Uri $uri2 -Headers $Headers).content > ".\_bak\couchdb\_users-_design-_auth.json"
(Invoke-WebRequest -Uri $uri3 -Headers $Headers).content > ".\_bak\couchdb\requests-_design-new.json"
Write-Host "Packing up ..."
7z.exe a -t7z "project_$(Get-Date -UFormat "%Y-%m-%d").7z" "main" "dev" -bd -mx9 -xr@".gitignore"
# ... DELETE old public_* folders
rm .\main\public_* -Recurse
read-host "Done. Press any key."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment