mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
Merge branch 'master' of https://gitlab.com/fyipe-project/app into feature-error-tracking
This commit is contained in:
@@ -567,6 +567,9 @@ router.post(
|
||||
try {
|
||||
const data = req.body;
|
||||
const incidentId = req.params.incidentId;
|
||||
const { idNumber } = await IncidentService.getIncidentId({
|
||||
_id: incidentId,
|
||||
});
|
||||
const projectId = req.params.projectId;
|
||||
const userId = req.user.id;
|
||||
if (!data.content) {
|
||||
@@ -776,6 +779,7 @@ router.post(
|
||||
);
|
||||
incidentMessage = {
|
||||
type: data.type,
|
||||
idNumber,
|
||||
data: await Services.rearrangeDuty(filteredMsg),
|
||||
};
|
||||
} else {
|
||||
@@ -822,6 +826,9 @@ router.delete(
|
||||
async function(req, res) {
|
||||
try {
|
||||
const { incidentId, incidentMessageId, projectId } = req.params;
|
||||
const { idNumber } = await IncidentService.getIncidentId({
|
||||
_id: incidentId,
|
||||
});
|
||||
const checkMsg = await IncidentMessageService.findOneBy({
|
||||
_id: incidentMessageId,
|
||||
});
|
||||
@@ -895,6 +902,7 @@ router.delete(
|
||||
);
|
||||
result = {
|
||||
type: checkMsg.type,
|
||||
idNumber,
|
||||
data: await Services.rearrangeDuty(filteredMsg),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -767,13 +767,26 @@ module.exports = {
|
||||
const userData = await UserService.findOneBy({
|
||||
_id: user._id,
|
||||
});
|
||||
|
||||
const identification = userData.identification;
|
||||
|
||||
webpush.setVapidDetails(
|
||||
process.env.PUSHNOTIFICATION_URL, // Address or URL for this application
|
||||
process.env.PUSHNOTIFICATION_PUBLIC_KEY, // URL Safe Base64 Encoded Public Key
|
||||
process.env.PUSHNOTIFICATION_PRIVATE_KEY // URL Safe Base64 Encoded Private Key
|
||||
const identification = userData.identification;
|
||||
console.log('IDENTIFICATION::', identification);
|
||||
|
||||
const options = {
|
||||
vapidDetails: {
|
||||
subject: process.env.PUSHNOTIFICATION_URL, // Address or URL for this application
|
||||
publicKey: process.env.PUSHNOTIFICATION_PUBLIC_KEY, // URL Safe Base64 Encoded Public Key
|
||||
privateKey: process.env.PUSHNOTIFICATION_PRIVATE_KEY, // URL Safe Base64 Encoded Private Key
|
||||
},
|
||||
};
|
||||
|
||||
console.log('PUSHNOTIFICATION_URL', process.env.PUSHNOTIFICATION_URL);
|
||||
console.log(
|
||||
'PUSHNOTIFICATION_PUBLIC_KEY',
|
||||
process.env.PUSHNOTIFICATION_PUBLIC_KEY
|
||||
);
|
||||
console.log(
|
||||
'PUSHNOTIFICATION_PRIVATE_KEY',
|
||||
process.env.PUSHNOTIFICATION_PRIVATE_KEY
|
||||
);
|
||||
|
||||
if (pushProgress) {
|
||||
@@ -793,7 +806,11 @@ module.exports = {
|
||||
for (const sub of identification) {
|
||||
promiseFuncs = [
|
||||
...promiseFuncs,
|
||||
webpush.sendNotification(sub.subscription, payload),
|
||||
webpush.sendNotification(
|
||||
sub.subscription,
|
||||
payload,
|
||||
options
|
||||
),
|
||||
];
|
||||
}
|
||||
return Promise.all(promiseFuncs)
|
||||
@@ -813,6 +830,8 @@ module.exports = {
|
||||
});
|
||||
})
|
||||
.catch(async e => {
|
||||
console.log('ERROR FROM PUSH::', e);
|
||||
console.log(e);
|
||||
return await _this.create({
|
||||
projectId: incident.projectId,
|
||||
monitorId: monitor._id,
|
||||
|
||||
@@ -6,7 +6,7 @@ test_js-sdk:
|
||||
- if [[ $next_stage == *"skip"* ]]; then exit ${CI_JOB_SKIP_EXIT_CODE:-0}; fi
|
||||
- sudo apt-get update
|
||||
- curl -sSL https://get.docker.com/ | sh #Install docker.
|
||||
- sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
|
||||
- sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev
|
||||
- echo "Setup machine for running log js tests"
|
||||
- sudo docker stop $(sudo docker ps -aq) || echo 'No docker containers'
|
||||
- sudo docker rm $(sudo docker ps -aq) || echo 'No docker containers'
|
||||
|
||||
@@ -858,7 +858,7 @@ export function setInternalNote(projectId, incidentId, body) {
|
||||
if (incidents.data.type === 'internal') {
|
||||
dispatch(
|
||||
fetchIncidentMessagesSuccess({
|
||||
incidentId,
|
||||
incidentId: incidents.data.idNumber,
|
||||
incidentMessages: incidents.data.data,
|
||||
count: incidents.data.data.length,
|
||||
type: incidents.data.type,
|
||||
@@ -1046,7 +1046,7 @@ export function deleteIncidentMessage(
|
||||
if (incidentMessage.data.type === 'internal') {
|
||||
dispatch(
|
||||
fetchIncidentMessagesSuccess({
|
||||
incidentId,
|
||||
incidentId: incidentMessage.data.idNumber,
|
||||
incidentMessages: incidentMessage.data.data,
|
||||
count: incidentMessage.data.data.length,
|
||||
type: incidentMessage.data.type,
|
||||
|
||||
@@ -468,7 +468,7 @@ export class MonitorDetail extends Component {
|
||||
You need to install an agent on your
|
||||
server, please{' '}
|
||||
<a
|
||||
href="https://www.npmjs.com/package/fyipe-server-monitor"
|
||||
href="https://github.com/Fyipe/js-sdk/blob/master/docs/server-monitor/README.md"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
style={{
|
||||
|
||||
@@ -12,8 +12,12 @@ import Domains from '../components/domains/Domains';
|
||||
|
||||
class DomainSettings extends React.Component {
|
||||
ready = () => {
|
||||
const { fetchCustomFields, match } = this.props;
|
||||
fetchCustomFields(match.params.projectId, 0, 10);
|
||||
const { fetchCustomFields } = this.props;
|
||||
fetchCustomFields(
|
||||
this.props.currentProject && this.props.currentProject._id,
|
||||
0,
|
||||
10
|
||||
);
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
@@ -23,7 +27,6 @@ class DomainSettings extends React.Component {
|
||||
render() {
|
||||
const {
|
||||
location: { pathname },
|
||||
match,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@@ -37,7 +40,12 @@ class DomainSettings extends React.Component {
|
||||
<BreadCrumbItem route={pathname} name="Domains" />
|
||||
|
||||
<div>
|
||||
<Domains projectId={match.params.projectId} />
|
||||
<Domains
|
||||
projectId={
|
||||
this.props.currentProject &&
|
||||
this.props.currentProject._id
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Fade>
|
||||
@@ -49,8 +57,8 @@ class DomainSettings extends React.Component {
|
||||
DomainSettings.displayName = 'DomainSettings';
|
||||
DomainSettings.propTypes = {
|
||||
location: PropTypes.object.isRequired,
|
||||
match: PropTypes.object,
|
||||
fetchCustomFields: PropTypes.func,
|
||||
currentProject: PropTypes.object.isRequired,
|
||||
};
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
|
||||
@@ -33,7 +33,7 @@ class ErrorEventView extends Component {
|
||||
? this.props.currentProject._id
|
||||
: null;
|
||||
const errorTrackerId = this.props.errorTracker
|
||||
? this.props.errorTracker._id
|
||||
? this.props.errorTracker[0]._id
|
||||
: null;
|
||||
const errorEventId = this.props.match.params.errorEventId
|
||||
? this.props.match.params.errorEventId
|
||||
@@ -152,7 +152,11 @@ const mapDispatchToProps = dispatch => {
|
||||
);
|
||||
};
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { componentId, errorTrackerSlug, errorEventId } = ownProps.match.params;
|
||||
const {
|
||||
componentId,
|
||||
errorTrackerSlug,
|
||||
errorEventId,
|
||||
} = ownProps.match.params;
|
||||
const currentErrorEvent = state.errorTracker.currentErrorEvent;
|
||||
const currentErrorEventId =
|
||||
currentErrorEvent !== errorEventId ? errorEventId : currentErrorEvent;
|
||||
|
||||
@@ -120,7 +120,6 @@ class IncidentSettings extends React.Component {
|
||||
render() {
|
||||
const {
|
||||
location: { pathname },
|
||||
match,
|
||||
} = this.props;
|
||||
const { skip, limit, count } = this.props.incidentPrioritiesList;
|
||||
const canPaginateForward =
|
||||
@@ -359,14 +358,20 @@ class IncidentSettings extends React.Component {
|
||||
<TabPanel>
|
||||
<Fade>
|
||||
<IncidentCommunicationSla
|
||||
projectId={match.params.projectId}
|
||||
projectId={
|
||||
this.props.currentProject &&
|
||||
this.props.currentProject._id
|
||||
}
|
||||
/>
|
||||
</Fade>
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<Fade>
|
||||
<IncidentCustomFields
|
||||
projectId={match.params.projectId}
|
||||
projectId={
|
||||
this.props.currentProject &&
|
||||
this.props.currentProject._id
|
||||
}
|
||||
/>
|
||||
</Fade>
|
||||
</TabPanel>
|
||||
@@ -393,7 +398,6 @@ IncidentSettings.propTypes = {
|
||||
PropTypes.object,
|
||||
PropTypes.oneOf([null, undefined]),
|
||||
]),
|
||||
match: PropTypes.object,
|
||||
fetchCustomFields: PropTypes.func,
|
||||
};
|
||||
const mapStateToProps = state => {
|
||||
|
||||
@@ -18,8 +18,12 @@ class MonitorSettings extends React.Component {
|
||||
};
|
||||
|
||||
ready = () => {
|
||||
const { fetchCustomFields, match } = this.props;
|
||||
fetchCustomFields(match.params.projectId, 0, 10);
|
||||
const { fetchCustomFields } = this.props;
|
||||
fetchCustomFields(
|
||||
this.props.currentProject && this.props.currentProject._id,
|
||||
0,
|
||||
10
|
||||
);
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
@@ -36,8 +40,7 @@ class MonitorSettings extends React.Component {
|
||||
|
||||
render() {
|
||||
const {
|
||||
location: { pathname },
|
||||
match,
|
||||
location: { pathname }
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@@ -86,14 +89,20 @@ class MonitorSettings extends React.Component {
|
||||
<TabPanel>
|
||||
<Fade>
|
||||
<MonitorSla
|
||||
projectId={match.params.projectId}
|
||||
projectId={
|
||||
this.props.currentProject &&
|
||||
this.props.currentProject._id
|
||||
}
|
||||
/>
|
||||
</Fade>
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<Fade>
|
||||
<MonitorCustomFields
|
||||
projectId={match.params.projectId}
|
||||
projectId={
|
||||
this.props.currentProject &&
|
||||
this.props.currentProject._id
|
||||
}
|
||||
/>
|
||||
</Fade>
|
||||
</TabPanel>
|
||||
@@ -109,8 +118,8 @@ class MonitorSettings extends React.Component {
|
||||
MonitorSettings.displayName = 'MonitorSettings';
|
||||
MonitorSettings.propTypes = {
|
||||
location: PropTypes.object.isRequired,
|
||||
match: PropTypes.object,
|
||||
fetchCustomFields: PropTypes.func,
|
||||
currentProject: PropTypes.object,
|
||||
};
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
|
||||
@@ -1190,4 +1190,4 @@ describe('API Monitor API', () => {
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -41,8 +41,7 @@ describe('Monitor Custom Field', () => {
|
||||
password: data.password,
|
||||
};
|
||||
// user
|
||||
await init.registerUser(user, page);
|
||||
await init.loginUser(user, page);
|
||||
await init.registerUser(user, page);
|
||||
});
|
||||
|
||||
done();
|
||||
@@ -80,6 +79,8 @@ describe('Monitor Custom Field', () => {
|
||||
visible: true,
|
||||
});
|
||||
await page.click('#projectSettings');
|
||||
await page.waitForSelector('#more');
|
||||
await page.click('#more');
|
||||
await page.waitForSelector('#monitor', { visible: true });
|
||||
await page.click('#monitor');
|
||||
await page.reload({
|
||||
@@ -126,6 +127,8 @@ describe('Monitor Custom Field', () => {
|
||||
visible: true,
|
||||
});
|
||||
await page.click('#projectSettings');
|
||||
await page.waitForSelector('#more');
|
||||
await page.click('#more');
|
||||
await page.waitForSelector('#monitor', { visible: true });
|
||||
await page.click('#monitor');
|
||||
await page.reload({
|
||||
|
||||
@@ -1023,4 +1023,4 @@ module.exports = {
|
||||
await page.click('#createCustomFieldButton');
|
||||
await page.waitForSelector('#customFieldForm', { visible: 'hidden' });
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -10,10 +10,14 @@ FYIPE_DB_PASSWORD='password'
|
||||
FYIPE_DB_NAME='fyipedb'
|
||||
CURRENT_DATE=$(date +%s)
|
||||
CURRENT_USER=$(whoami)
|
||||
BACKUP_PATH="/Users/$CURRENT_USER/Documents/backup"
|
||||
BACKUP_PATH=~/Documents/backup
|
||||
BACKUP_RETAIN_DAYS=14
|
||||
TODAY=`date +"%d%b%Y"`
|
||||
|
||||
red=`tput setaf 1`
|
||||
green=`tput setaf 2`
|
||||
reset=`tput sgr 0`
|
||||
|
||||
function HELP (){
|
||||
echo ""
|
||||
echo "Fyipe DB backup command line documentation."
|
||||
@@ -140,16 +144,16 @@ if sudo kubectl exec fi-mongodb-primary-0 -- mongodump --uri="mongodb://$FYIPE_D
|
||||
echo "Copying backup from server to local computer. This will take some time...."
|
||||
echo ""
|
||||
if sudo kubectl cp fi-mongodb-primary-0:tmp/fyipedata.archive "$BACKUP_PATH/fyipe-backup-$CURRENT_DATE.archive"; then
|
||||
echo "File Saved: $BACKUP_PATH/fyipe-backup-$CURRENT_DATE.archive"
|
||||
echo ${green}"File Saved: $BACKUP_PATH/fyipe-backup-$CURRENT_DATE.archive"${reset}
|
||||
echo ""
|
||||
BACKUP_SUCCESS
|
||||
|
||||
else
|
||||
echo "Failure, exit status: $?"
|
||||
echo ${red}"Failure, exit status: $?" ${reset}
|
||||
BACKUP_FAIL_LOCAL
|
||||
fi
|
||||
else
|
||||
echo "Failure, exit status: $"
|
||||
echo ${red}"Failure, exit status: $"${reset}
|
||||
BACKUP_FAIL_SERVER
|
||||
fi
|
||||
|
||||
@@ -158,4 +162,4 @@ fi
|
||||
echo "Removing backup older than ${BACKUP_RETAIN_DAYS} days."
|
||||
find $BACKUP_PATH* -mtime +${BACKUP_RETAIN_DAYS} -exec rm {} \;
|
||||
echo ""
|
||||
echo "Done"
|
||||
echo "Done"
|
||||
|
||||
@@ -1,60 +1,49 @@
|
||||
# Fyipe Database Backup/Restore
|
||||
|
||||
To carry out backup/restore of the fyipe database on a remote virtual machine, you first have to setup your local system to acess the remote cluster.
|
||||
|
||||
## Set up local VM
|
||||
|
||||
- ssh into the local VN and upload scripts install.sh, backup.sh and restore.sh to the root user.
|
||||
|
||||
The script install.sh will automatically install the latest kubectl version if non is present, create default backup path and kube-config paths as well as copy the remote server kubernetes config file.
|
||||
|
||||
- Open a new terminal on the VN and run script: `install.sh -a <IP_ADDRESS>`
|
||||
|
||||
The _IP_ADDRESS_ is the address of remote server where database is hosted.
|
||||
|
||||
You will be asked for the password.
|
||||
|
||||
Proceed to backup or restore.
|
||||
|
||||
## Backing up the database
|
||||
|
||||
**_Step 1 : Test backup_**
|
||||
**_Step 1 : Files Upload_**
|
||||
|
||||
- ssh into the local VN and upload scripts install.sh, backup.sh and restore.sh to `/root/fyipe_bk_files`.
|
||||
|
||||
The script install.sh will automatically install the latest kubectl version if non is present, create default backup and kube-config paths, copy the remote server kubernetes config file, create backup service and run the service with a timer.
|
||||
|
||||
**_Step 2 : Pass Arguments_**
|
||||
|
||||
The first thing to take note of is passing the right arguments.
|
||||
|
||||
- cd into folder containing backup script.
|
||||
- Enter command `bash backup.sh -h` to see list of all available commands
|
||||
- cd into folder containing install scripts `/root/fyipe_bk_files`.
|
||||
- Enter command `bash install.sh -h` to see list of all available commands
|
||||
|
||||
| Argument | Function | Default |
|
||||
| -------- | :------------------------------------------------------------------------------ | :--------------------------- |
|
||||
| -l | Backup path on local system where backup file will be stored. | /Users/root/Documents/backup |
|
||||
| -n | Database name. | 'fyipedb' |
|
||||
| -p | Database password. | 'password' |
|
||||
| -r | Helm release name. | 'fi' |
|
||||
| -t | Backup retain days. Set the number of days backup is kept before it is deleted. | 14 |
|
||||
| -u | Set database username. | 'fyipe' |
|
||||
| -h | Help | null |
|
||||
| Argument | Function | Default |
|
||||
| -------- | :------------------------------------------------------------------------------ | :------------------------------ |
|
||||
| -a | IP Address of remote server | No Default. Compulsory argument |
|
||||
| -l | Backup path on local system where backup file will be stored. | /root/Documents/backup |
|
||||
| -n | Database name. | 'fyipedb' |
|
||||
| -p | Database password. | 'password' |
|
||||
| -t | Backup retain days. Set the number of days backup is kept before it is deleted. | 14 |
|
||||
| -u | Set database username. | 'fyipe' |
|
||||
| -h | Help | null |
|
||||
|
||||
_ex: To create a backup of a database without username or password and database name is 'fyipe'_
|
||||
|
||||
The command will be `bash backup.sh -u '' -p '' -n 'fyipe'`
|
||||
The command will be `bash install.sh -u '' -p '' -n 'fyipe'`
|
||||
|
||||
**_Step 2 : Set-up a cronJob_**
|
||||
**_Step 3 : Run backup_**
|
||||
|
||||
- Update the computer’s local package index: `sudo apt update`.
|
||||
- Install cron: `sudo apt install cron`.
|
||||
- Set it to run on background: `sudo systemctl enable cron`.
|
||||
- Simply hit the enter button, enter the remote server password and any other credentials being requested for.
|
||||
|
||||
The next step is to schedule the job
|
||||
- A timer (backup.timer) which runs service (backup.service) has been created to back up the database at 12:00 am and 12:00 pm daily. Useful commands include:
|
||||
|
||||
- Visit `https://crontab.guru/` to create a cron schedule.
|
||||
- Edit user crontab: `crontab -e`
|
||||
- Select your default text editor _(For first time use)_
|
||||
- Proceed to schedule your job. For example, to backup the database every 12 hours, the command would be
|
||||
`sudo systemctl status backup.service` to check status of the service
|
||||
|
||||
`0 */12 * * * /root/scripts/backup.sh -u '' -p '' -n 'fyipe'`
|
||||
`journalctl -u backup.service` to view logs
|
||||
|
||||
- Save crontab and exit.
|
||||
`sudo systemctl status backup.timer` to check if timer is running and time left to when the service will be ran next.
|
||||
|
||||
`sudo systemctl stop backup.timer` to pause backup
|
||||
|
||||
`sudo systemctl start backup.timer` to start backup
|
||||
|
||||
## Restore a backup
|
||||
|
||||
@@ -63,17 +52,15 @@ The first thing to take note of is passing the right arguments.
|
||||
- cd into folder containing backup script.
|
||||
- Enter command `bash backup.sh -h` to see list of all available commands
|
||||
|
||||
| Argument | Function | Default |
|
||||
| -------- | :------------------------------------------------------------------------------ | :---------------------------- |
|
||||
| -f | Name of file to be restored. | No default. Compulsary field. |
|
||||
| -l | File path on local system where file will be restored from. | /Users/root/Documents/backup |
|
||||
| -n | Database name. Default value | 'fyipedb' |
|
||||
| -p | Database password. Default value | 'password' |
|
||||
| -r | Helm release name. | 'fi' |
|
||||
| -t | Backup retain days. Set the number of days backup is kept before it is deleted. | 14 |
|
||||
| -u | Set database username. | 'fyipe' |
|
||||
| -h | Help | null |
|
||||
| Argument | Function | Default |
|
||||
| -------- | :---------------------------------------------------------- | :------------------------------- |
|
||||
| -f | Name of file to be restored. | No default. Compulsory argument. |
|
||||
| -l | File path on local system where file will be restored from. | /root/Documents/backup |
|
||||
| -n | Database name. Default value | 'fyipedb' |
|
||||
| -p | Database password. Default value | 'password' |
|
||||
| -u | Set database username. | 'fyipe' |
|
||||
| -h | Help | null |
|
||||
|
||||
_ex: To restore a backup with name fyipe-backup-1613551425.archive to a database without username or password and database name is 'fyipe'._
|
||||
|
||||
The command will be `/<Path to script> bash restore.sh -f fyipe-backup-1613551425.archive -p '' -u ''`
|
||||
The command will be `/root/fyipe_bk_files bash restore.sh -f fyipe-backup-1613551425.archive -p '' -u ''`
|
||||
|
||||
@@ -1,27 +1,49 @@
|
||||
# !/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
IP_ADDRESS=1
|
||||
FYIPE_DB_USERNAME='fyipe'
|
||||
FYIPE_DB_PASSWORD='password'
|
||||
FYIPE_DB_NAME='fyipedb'
|
||||
BACKUP_RETAIN_DAYS=14
|
||||
BACKUP_PATH=~/Documents/backup
|
||||
|
||||
red=`tput setaf 1`
|
||||
green=`tput setaf 2`
|
||||
reset=`tput sgr 0`
|
||||
|
||||
function HELP (){
|
||||
echo ""
|
||||
echo "Fyipe DB backup command line documentation."
|
||||
echo ""
|
||||
echo "all arguments are optional and have a default value when not set"
|
||||
echo "optional arguments have a default value when not set"
|
||||
echo ""
|
||||
echo " -a IP address of remote server."
|
||||
echo " -a IP address of remote server. (Compulsory)"
|
||||
echo " -l Backup path on local system where backup file will be stored. Default value - $BACKUP_PATH"
|
||||
echo " -n Database name. Default value 'fyipedb'"
|
||||
echo " -p Database password. Default value 'password'"
|
||||
echo " -u Set database username. Default value 'fyipe'."
|
||||
echo " -t Backup retain days. Number of days backup is kept before it is deleted. Default value '14'"
|
||||
echo ""
|
||||
echo " -h Help."
|
||||
echo " -h Help."
|
||||
echo ""
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
# PASS IN ARGUMENTS
|
||||
while getopts ":a:v" opt; do
|
||||
while getopts ":a:l:p:n:t:u:h" opt; do
|
||||
case $opt in
|
||||
a) IP_ADDRESS="$OPTARG"
|
||||
;;
|
||||
v) KUBECTL_VERSION="$OPTARG"
|
||||
l) BACKUP_PATH="$OPTARG"
|
||||
;;
|
||||
p) FYIPE_DB_PASSWORD="$OPTARG"
|
||||
;;
|
||||
n) FYIPE_DB_NAME="$OPTARG"
|
||||
;;
|
||||
t) BACKUP_RETAIN_DAYS="$OPTARG"
|
||||
;;
|
||||
u) FYIPE_DB_USERNAME="$OPTARG"
|
||||
;;
|
||||
h) HELP
|
||||
;;
|
||||
@@ -37,25 +59,67 @@ if [[ $IP_ADDRESS == 1 ]]
|
||||
then
|
||||
HELP
|
||||
else
|
||||
|
||||
|
||||
#Install Docker and setup registry and insecure access to it.
|
||||
|
||||
#Step 1: Install Docker and setup registry and insecure access to it.
|
||||
if [[ ! $(which kubectl) ]]
|
||||
then
|
||||
#Install Kubectl
|
||||
echo "RUNNING COMMAND: curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
|
||||
echo "RUNNING COMMAND: chmod +x ./kubectl"
|
||||
chmod +x ./kubectl
|
||||
echo "RUNNING COMMAND: sudo mv ./kubectl /usr/local/bin/kubectl"
|
||||
sudo mv ./kubectl /usr/local/bin/kubectl
|
||||
#Install Kubectl
|
||||
echo "RUNNING COMMAND: curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
|
||||
echo "RUNNING COMMAND: chmod +x ./kubectl"
|
||||
chmod +x ./kubectl
|
||||
echo "RUNNING COMMAND: sudo mv ./kubectl /usr/local/bin/kubectl"
|
||||
sudo mv ./kubectl /usr/local/bin/kubectl
|
||||
fi
|
||||
|
||||
# STEP 2: create directories
|
||||
# STEP 2: create directories
|
||||
mkdir -p ~/.kube
|
||||
mkdir -p ~/Documents/backup
|
||||
mkdir -p ${BACKUP_PATH}
|
||||
|
||||
# STEP 3: copy remote kube config and replace local
|
||||
if scp root@${IP_ADDRESS}:~/.kube/config ~/.kube
|
||||
then echo "Copied .kube config file"
|
||||
else
|
||||
echo ${red}'Could not copy .kube file from remote server. Please manually copy the file to '$HOME/.kube/config ${reset}
|
||||
fi
|
||||
|
||||
# STEP 4 : create service file for backup
|
||||
echo '
|
||||
[Unit]
|
||||
Description=Fyipe database backup
|
||||
|
||||
[Service]
|
||||
ExecStart=bash '"$HOME"'/fyipe_bk_files/backup.sh -u '${FYIPE_DB_USERNAME}' -p '${FYIPE_DB_PASSWORD}' -n '${FYIPE_DB_NAME}' -l '${BACKUP_PATH}' -t '${BACKUP_RETAIN_DAYS}'
|
||||
|
||||
' > /etc/systemd/system/backup.service
|
||||
|
||||
|
||||
#Step 5: Set up timer to run service every 12 hours
|
||||
echo '
|
||||
[Unit]
|
||||
Description= 12 hours Fyipe backup
|
||||
Requires=backup.service
|
||||
|
||||
[Timer]
|
||||
Unit=backup.service
|
||||
OnCalendar=*-*-* 00,12:00:00
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
' > /etc/systemd/system/backup.timer
|
||||
|
||||
# STEP 6: make files.sh executable
|
||||
chmod +x "$HOME"/fyipe_bk_files/backup.sh
|
||||
|
||||
chmod +x "$HOME"/fyipe_bk_files/restore.sh
|
||||
|
||||
# STEP 7: Start timer
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
sudo systemctl enable backup.timer
|
||||
|
||||
sudo systemctl start backup.timer
|
||||
|
||||
# STEP: copy remote kube config and replace local
|
||||
scp root@${IP_ADDRESS}:~/.kube/config ~/.kube
|
||||
fi
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ function HELP (){
|
||||
echo " -l File path on local system where file will be restored from. Default value - $FILE_PATH"
|
||||
echo " -n Database name. Default value 'fyipe'"
|
||||
echo " -p Database password. Default value 'password'"
|
||||
echo " -r Helm release name. Default value 'fi'"
|
||||
echo " -u Set database username. Default value 'fyipe'."
|
||||
echo ""
|
||||
echo " -h Help."
|
||||
|
||||
@@ -299,7 +299,7 @@ npm test
|
||||
|
||||
## Server Monitor
|
||||
|
||||
Please see [Fyipe Server Monitor](https://www.npmjs.com/package/fyipe-server-monitor) for more information on how to use this package.
|
||||
Please see [Fyipe Server Monitor](https://github.com/Fyipe/js-sdk/blob/master/docs/server-monitor/README.md) for more information on how to use this package.
|
||||
|
||||
### Dependencies
|
||||
|
||||
|
||||
5
js-sdk/.gitignore
vendored
5
js-sdk/.gitignore
vendored
@@ -1,2 +1,5 @@
|
||||
test.html
|
||||
/node_modules
|
||||
/node_modules
|
||||
|
||||
/build
|
||||
/dist
|
||||
278
js-sdk/dist/fyipe.js
vendored
278
js-sdk/dist/fyipe.js
vendored
File diff suppressed because one or more lines are too long
287
js-sdk/dist/fyipe.min.js
vendored
287
js-sdk/dist/fyipe.min.js
vendored
File diff suppressed because one or more lines are too long
8466
js-sdk/package-lock.json
generated
8466
js-sdk/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,10 @@
|
||||
"scripts": {
|
||||
"preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'",
|
||||
"build-dev": "npm run build && npm link",
|
||||
"build-cli": "babel src/cli -d build --copy-files",
|
||||
"build-sdk": "webpack --mode production",
|
||||
"test": "mocha --require @babel/polyfill --require @babel/register \"test/**/*.test.js\" \"src/**/*.test.js\"",
|
||||
"build": "webpack --mode production",
|
||||
"build": "npm run build-cli && npm run build-sdk",
|
||||
"audit": "npm audit --audit-level=low",
|
||||
"dep-check": "depcheck ./ --skip-missing=true --ignores='axios,webpack-cli,babel-loader,depcheck,mocha,webpack'"
|
||||
},
|
||||
@@ -25,6 +27,7 @@
|
||||
"author": "HackerBay, Inc.",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.13.10",
|
||||
"@babel/core": "^7.10.2",
|
||||
"@babel/plugin-proposal-class-properties": "^7.10.1",
|
||||
"@babel/plugin-proposal-private-methods": "^7.10.1",
|
||||
|
||||
@@ -182,9 +182,7 @@ const ping = (
|
||||
* @return {Object} The server monitor handlers.
|
||||
*/
|
||||
|
||||
// BUG FIX: TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
|
||||
// change export to es6 module export
|
||||
export default function(config, apiUrl, apiKey, monitorId) {
|
||||
module.exports = function(config, apiUrl, apiKey, monitorId) {
|
||||
let pingServer,
|
||||
projectId = config,
|
||||
interval,
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
|
||||
<section>
|
||||
<article><p><a href="https://www.npmjs.com/package/fyipe-server-monitor"><img src="https://img.shields.io/npm/v/fyipe-server-monitor" alt="npm"></a></p>
|
||||
<article><p><a href="https://github.com/Fyipe/js-sdk/blob/master/docs/server-monitor/README.md"><img src="https://img.shields.io/npm/v/fyipe-server-monitor" alt="npm"></a></p>
|
||||
<h1>Fyipe Server Monitor</h1>
|
||||
<p>A fyipe shell package that monitor's server resources - disk, memory and CPU percentage - used.</p>
|
||||
<h2>Installation</h2>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import Logger from './logger.js';
|
||||
import ErrorTracker from './tracker.js';
|
||||
import ServerMonitor from './cli/server-monitor/lib/api';
|
||||
// Due to issue with handling exports/imports in the server-monitor cli
|
||||
// we need to build the server-monitor project into the build folder then point to it there
|
||||
// This way we won't worry about whether we are using module/commonjs syntax
|
||||
import ServerMonitor from '../build/server-monitor/lib/api';
|
||||
|
||||
export default { Logger, ErrorTracker, ServerMonitor };
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('FyipeLogger', function() {
|
||||
|
||||
before(function(done) {
|
||||
this.timeout(60000);
|
||||
sleep(30000).then(() => {
|
||||
sleep(5000).then(() => {
|
||||
user.email = generateRandomBusinessEmail();
|
||||
request
|
||||
.post('/user/signup')
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('Tracker Timeline', function() {
|
||||
|
||||
before(function(done) {
|
||||
this.timeout(60000);
|
||||
sleep(30000).then(() => {
|
||||
sleep(5000).then(() => {
|
||||
user.email = generateSecondRandomBusinessEmail();
|
||||
request
|
||||
.post('/user/signup')
|
||||
|
||||
Reference in New Issue
Block a user