Skip to content

Instantly share code, notes, and snippets.

@BananaAcid
Created March 14, 2020 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BananaAcid/26030b217f7478ee498e6cf42f54adfd to your computer and use it in GitHub Desktop.
Save BananaAcid/26030b217f7478ee498e6cf42f54adfd to your computer and use it in GitHub Desktop.
Pack up a project and some couchdb docs
node_modules
.gitignore
thumbs.db
# related to https://gist.github.com/BananaAcid/af2afa89c086de210c2fd647335b80f0
$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