Skip to content

Hajitsu/backing-up

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BackUp From Everything With #ShellScript

Story of the project

Hi! I'm Hajitsu. In the office, we have servers to do our work. On one of the servers, Gitlab-CE is installed to manage our repositories. I have a concern about backup repositories per day. So I deployed a bash script to backup repositories and upload it to Telegram's private channel. Because of the banned Telegram in Iran, I have to develop an API to upload files by the bash script to it, and then the API sends it to Telegram's private channel. The API is on VPS in Finland. I also decided to deploy these scripts to backup from our files on Windows Server or PFSense.

Shell Script

Gitlab to use the script to backup Gitlab-CE, first, create a config file .git-backup.config in the root of the shell-script folder like this:

destination_share=/media/GitBackup
temp_path=/home/USERNAME/temp
seperate_size=20m
api_url=http://VPS_IP:PORT/dep/git

Notice

by destination_share,, you can copy a backup file to a shared folder.

Because of Telegram limitations, the bot upload document limitation is 20M (seperate_size).

Node JS API

To use NodeJS API, you have to create a .env file in the root of the project like this:

BOT_ID=XXXXXXXX
CHAT_ID=XXXXXXX

Define cronjob

For creating a backup every X time, like every day or every hour, use the following command:

crontab -e

Then use Crontab Guru to create a cronjob, then complete the cronjob as below:

14 0 * * * /bin/bash /PATH_TO_YOUR_SCRIPT/git-backup.sh>>/PATH_TO_YOUR_LOG_FILE/log.log

This cronjob runs at 00:14 every day.

Recommendation

to start the API, you can use PM2 by pm2 start app.js command.

About

BackUp From Everything With #ShellScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published