George McKinney Adventures in Software Development

January 11, 2021

Cloudant undeleting a user account

Filed under: Cloud,Cloudant,IBM,IBM Cloud — georgemck @ 6:58 pm

The following procedure can be used to undelete a user document in Cloudant.

First, login to the Cloudant database as an administrator. Use an Administrator’s username and password. Only admins have access to the _users table.

The previously deleted document needs to be retrieved from the database. However, since it has been deleted, all requests for it will fail. You can instead download a file of all deleted revisions for document by browser url as a get request, e.g. https://ACCOUNTUSERNAME-bluemix.cloudant.com/_users/TARGETUSERDOCUMENT/?revs=true&open_revs=all. Looking through the downloaded file, create a target revision working from the most recent. After creating the target revision, you can use it to retrieve it’s document. In the downloaded file, take the latest revision and subtract one from its number, then look at the top of the list of revision ids and get the second one and use it as the TARGETREVISION. It will be immediately following the last revision id. Now the specific revision of the document can be retrieved by browser url get request, e.g. https://ACCOUNTUSERNAME-bluemix.cloudant.com/_users/TARGETUSERDOCUMENT/?rev=TARGETREVISION

The retrieved document will contain the “_rev”. Delete it. Use the rest of the document revision in a put/post/insert into the database to restore it as the version of the document, thus undeleting a user document in Cloudant.

//This Node.js program will restore the deleted user document.

var ACCOUNTUSERNAME = ‘aaa-bbb-ccc-ddd-eee-bluemix’;
var PASSWORD = ‘@dministrator$ecretP@ssW0rd’;

var TARGETUSERDOCUMENT = “org.couchdb.user:randomuserXYZ123@gmail.com”;
var USERDOCUMENTREVISION = {
“_id”: TARGETUSERDOCUMENT,
“name”: “randomuserXYZ123@gmail.com”,
“roles”: [],
“type”: “user”,
“password_scheme”: “pbkdf2”,
“iterations”: 111,
“derived_key”: “9dbbd43599b6fdae170bb6990e9afca99881f6e7”,
“salt”: “e0b6331fe04fc2aef4b152de70fac8d8”,
“updateTime”: “2021-01-11T23:52:45.006Z”
};

var Cloudant = require(‘cloudant’);

var cloudant = Cloudant({
account: ACCOUNTUSERNAME,
key: ACCOUNTUSERNAME,
password: PASSWORD
});

var db = cloudant.db.use(‘_users’);

db.insert(USERDOCUMENTREVISION, function (err, result) {
if (err) {
throw err;
}
});

Also at https://github.com/georgemck/cloudant-utils/blob/main/restore-deleted-user-account

Based on information from:
http://garmoncheg.blogspot.com/2013/11/couchdb-restoring-deletedupdated.html

January 2, 2021

AWS CloudShell Homebrew Install Process

Filed under: AWS — georgemck @ 10:35 pm

 

1. Clone.

git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew

2. Compile.

mkdir ~/.linuxbrew/bin

3. Link.

ln -s ../Homebrew/bin/brew ~/.linuxbrew/bin

4. Update environment.

eval $(~/.linuxbrew/bin/brew shellenv)

AWS CloudShell CLI Update Process

Filed under: Amazon,AWS — georgemck @ 8:36 pm

Quick Procedure to update the AWS CloudShell available for IAM user accounts following instructions per

https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html

 

curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip” -o “awscliv2.zip”

unzip awscliv2.zip

sudo ./aws/install

 

 

AWS Shell Curl command
AWS Shell Unzip command
AWS Shell update command

Powered by WordPress