* Removed unused get note diff function. It doesn't work because everything is encrypted now
* Added a script to sync down the prod database and files to dev
This commit is contained in:
parent
941d21d9cb
commit
c7e342be4d
43
applyProdDatabaseToDev.sh
Executable file
43
applyProdDatabaseToDev.sh
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo '-------'
|
||||||
|
echo 'Starting Database Restore'
|
||||||
|
echo '-------'
|
||||||
|
|
||||||
|
#get Latest database backup
|
||||||
|
|
||||||
|
# Unzip File
|
||||||
|
# gzip -dk file.gz
|
||||||
|
|
||||||
|
BACKUPDIR="/home/mab/databaseBackupSolidScribe"
|
||||||
|
DEVDBPASS="Crama!Lama*Jamma###88383!!!!!345345956245i"
|
||||||
|
|
||||||
|
cd $BACKUPDIR
|
||||||
|
|
||||||
|
# -t sort by modification time, newest first
|
||||||
|
# -A --almost-all, do not list implied . and ..
|
||||||
|
LASTZIPPEDFILE=$(ls -At *.gz | head -n1)
|
||||||
|
|
||||||
|
# -k keep file after unzip
|
||||||
|
# -d Decompress
|
||||||
|
# -v verbose
|
||||||
|
echo "Unzipping $LASTZIPPEDFILE"
|
||||||
|
gunzip -dkv $LASTZIPPEDFILE
|
||||||
|
|
||||||
|
BACKUPFILE=$(ls -At *.sql | head -n1)
|
||||||
|
|
||||||
|
#Fix to replace incompatible DB type
|
||||||
|
echo "Updating table name in $BACKUPFILE"
|
||||||
|
sed -i $BACKUPFILE -e 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g'
|
||||||
|
|
||||||
|
echo "Removing and syncing static files"
|
||||||
|
rm -r /home/mab/ss/staticFiles/*
|
||||||
|
rsync -e 'ssh -p 13328' -hazC --update mab@solidscribe.com:/home/mab/pi/staticFiles /home/mab/ss/
|
||||||
|
|
||||||
|
echo "Updating Database"
|
||||||
|
mysql -u root --password="$DEVDBPASS" < $BACKUPFILE
|
||||||
|
rm *.sql
|
||||||
|
|
||||||
|
echo '-------'
|
||||||
|
echo "Applied Prod database to Dev. LastFile: $BACKUPFILE"
|
||||||
|
echo '-------'
|
@ -1,18 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
BACKUPDIR="/home/mab/databaseBackupPi"
|
BACKUPDIR="/home/mab/databaseBackupSolidScribe"
|
||||||
|
|
||||||
mkdir -p $BACKUPDIR
|
mkdir -p $BACKUPDIR
|
||||||
cd $BACKUPDIR
|
cd $BACKUPDIR
|
||||||
|
|
||||||
NOW=$(date +"%Y-%m-%d_%H-%M")
|
NOW=$(date +"%Y-%m-%d_%H-%M")
|
||||||
ssh mab@solidscribe.com -p 13328 "mysqldump --all-databases --user root -p***REMOVED***" > "backup-$NOW.sql"
|
ssh mab@solidscribe.com -p 13328 "mysqldump --all-databases --single-transaction --user root -p***REMOVED***" > "backup-$NOW.sql"
|
||||||
|
gzip "backup-$NOW.sql"
|
||||||
|
|
||||||
cp "backup-$NOW.sql" "/mnt/Windows Data/DatabaseBackups/backup-$NOW.sql"
|
cp "backup-$NOW.sql" "/mnt/Windows Data/DatabaseBackups/backup-$NOW.sql"
|
||||||
|
|
||||||
echo "Database Backup Complete on $NOW"
|
echo "Database Backup Complete on $NOW"
|
||||||
|
|
||||||
|
##
|
||||||
# Restore DB
|
# Restore DB
|
||||||
|
##
|
||||||
|
|
||||||
# copy file over, run restore
|
# copy file over, run restore
|
||||||
# scp -P 13328 backup-2019-12-04_03-00.sql mab@avidhabit.com:/home/mab
|
# scp -P 13328 backup-2019-12-04_03-00.sql mab@avidhabit.com:/home/mab
|
||||||
# mysql -u root -p < backup-2019-12-04_03-00.sql
|
# mysql -u root -p < backup-2019-12-04_03-00.sql
|
||||||
|
|
||||||
|
##
|
||||||
|
# Crontab setup
|
||||||
|
##
|
||||||
|
|
||||||
|
# 0 2 * * * /bin/bash /home/mab/ss/backupDatabase.sh 1> /home/mab/databaseBackupLog.txt
|
@ -954,20 +954,6 @@
|
|||||||
console.log('Focus regained with note open.')
|
console.log('Focus regained with note open.')
|
||||||
console.log('Attempting to fix diff text. fix this. Search spleen')
|
console.log('Attempting to fix diff text. fix this. Search spleen')
|
||||||
return
|
return
|
||||||
|
|
||||||
axios.post('/api/note/difftext', postData)
|
|
||||||
.then( ({data}) => {
|
|
||||||
|
|
||||||
//Don't do anything if nothing has changed
|
|
||||||
if(data == ''){ return }
|
|
||||||
|
|
||||||
if(data.diffs > 0){
|
|
||||||
//Update text and last updated time for note
|
|
||||||
this.setText(data.updatedText)
|
|
||||||
this.updated = data.updated
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => { this.$bus.$emit('notification', 'Failed to get diff') })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Track visibility state
|
//Track visibility state
|
||||||
|
@ -658,60 +658,6 @@ Note.delete = (userId, noteId, masterKey = null) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//text is the current text for the note that will be compared to the text in the database
|
|
||||||
Note.getDiffText = (userId, noteId, usersCurrentText, lastUpdated) => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
Note.get(userId, noteId)
|
|
||||||
.then(noteObject => {
|
|
||||||
|
|
||||||
if(!noteObject.text || !usersCurrentText || noteObject.encrypted == 1){
|
|
||||||
return resolve(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
let oldText = noteObject.text.replace(/(\r\n|\n|\r)/gm,"")
|
|
||||||
let newText = usersCurrentText.replace(/(\r\n|\n|\r)/gm,"")
|
|
||||||
|
|
||||||
if(noteObject.updated == lastUpdated){
|
|
||||||
// console.log('No note diff')
|
|
||||||
return resolve(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
if(noteObject.updated > lastUpdated){
|
|
||||||
newText = noteObject.text.replace(/(\r\n|\n|\r)/gm,"")
|
|
||||||
oldText = usersCurrentText.replace(/(\r\n|\n|\r)/gm,"")
|
|
||||||
}
|
|
||||||
|
|
||||||
const dmp = new DiffMatchPatch.diff_match_patch()
|
|
||||||
const diff = dmp.diff_main(oldText, newText)
|
|
||||||
|
|
||||||
dmp.diff_cleanupSemantic(diff)
|
|
||||||
const patch_list = dmp.patch_make(oldText, newText, diff);
|
|
||||||
const patch_text = dmp.patch_toText(patch_list);
|
|
||||||
|
|
||||||
//Patch text - shows a list of changes
|
|
||||||
var patches = dmp.patch_fromText(patch_text);
|
|
||||||
// console.log(patch_text)
|
|
||||||
|
|
||||||
//results[1] - contains diagnostic data for patch apply, its possible it can fail
|
|
||||||
var results = dmp.patch_apply(patches, oldText);
|
|
||||||
|
|
||||||
//Compile return data for front end
|
|
||||||
const returnData = {
|
|
||||||
updatedText: results[0],
|
|
||||||
diffs: results[1].length, //Only use length for now
|
|
||||||
updated: Math.max(noteObject.updated,lastUpdated) //Return most recently updated date
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Final change in notes
|
|
||||||
// console.log(returnData)
|
|
||||||
|
|
||||||
resolve(returnData)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Note.get = (userId, noteId, masterKey) => {
|
Note.get = (userId, noteId, masterKey) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
@ -60,14 +60,6 @@ router.post('/search', function (req, res) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/difftext', function (req, res) {
|
|
||||||
Note.getDiffText(userId, req.body.noteId, req.body.text, req.body.updated)
|
|
||||||
.then( fullDiffText => {
|
|
||||||
//Response should be full diff text
|
|
||||||
res.send(fullDiffText)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
router.post('/reindex', function (req, res) {
|
router.post('/reindex', function (req, res) {
|
||||||
Note.reindex(userId, masterKey)
|
Note.reindex(userId, masterKey)
|
||||||
.then( data => {
|
.then( data => {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo 'Make sure this is being run from root folder of project'
|
cd /home/mab/ss
|
||||||
|
|
||||||
echo 'Starting Client webpack dev server (/app), in a screen, watching for file changes...'
|
echo '::--:: Starting dev server. cd client; npm run serve -> 192.168.1.164:8081'
|
||||||
screen -dm bash -c "cd client/; npm run watch"
|
screen -dmS "NoteClientScreen" bash -c "cd /home/mab/ss/client; npm run serve"
|
||||||
|
|
||||||
echo 'Starting API server (/api), watching for file changes...'
|
echo '::--:: Starting API server (/api), watching for file changes...'
|
||||||
cd server
|
cd /home/mab/ss/server
|
||||||
pm2 start ecosystem.config.js
|
pm2 start ecosystem.config.js
|
Loading…
Reference in New Issue
Block a user