Author @vasilevkirill My Web Site
Pupirka is a Application for simple execute command in ssh server and response save in file, supported SSH LocalPort Forward.
- Pupirka - this not service
- Pupirka - this not used external library
- Pupirka - running one binary and save backup from all MikroTik or other devices
- Pupirka - Supported all Operating System if supported Golang
For download your need used this link Save binary for your Operating System
- Get source
You need use git and clone repository in your system
git clone https://github.com/vasilevkirill/pupirka.git
- Compily from source
Your need installed go and running command
cd pupirka
go get -d ./...
go build -ldflags "-s" -o pupirka .
your binary set name pupirka if your used nix*like set execute permission chmod +x pupirka
If your first run pupirka, needed running once
./pupirka
Pupirka automated Created required directories and config file pupirka.config.json
.
Needed added json
file in folder device
. File name is name device. (Example mydevice-01.json
Pupirka used file name as device name mydevice-01
)
{
"address": "111.222.223.222",
"username": "backupuserssh",
"password": "asdlmhas,o9duajsp9odj"
}
Paprika connected to SSH server in address and auth used credential from json
file.
Running command /export
(Default) and saved response in file ./backup/mydevice-01/20200903T2210.rsc
if you need automated backup used cron in unix or scheduler in Windows, running pupirka
.
{
"address": "111.222.223.222",
"username": "backupuserssh",
"password": "asdlmhas,o9duajsp9odj",
"portssh": 22,
"timeout": 10,
"every": 3600,
"rotate": 730,
"parent": "mydevice-02",
"timeformat": "20060102T1504",
"prefix": "rootR1-",
"filenameformat": "%p%t.rcs",
"key":"blabla.key",
"clearstring":"",
"hook": {
"backup": "",
"error": "",
"skip": ""
}
}
All supported parameter in json
file for device
portssh
- if your device running or access not 22 (default) port ssh, set needed tcp port.timeout
- if your device very slow response, set needed time wait in second.every
- how often to backup, check the time of the last file and if the difference with the current time is greater than the time of the file, a backup will be created.rotate
- delete old files backups older than days. (in order not to accidentally delete all backups, the deletion will occur if ONLY the count of backup files is more than (5) five files.)command
- execute command on remote device, if you need backup only firewall in mikrotik (/ip firewall export
)parent
- if your devices are behind the device and are not directly accessible, you can use this parameter. Specify the name of the device through which you want to establish a connection.timeformat
- as generate time string in file backup. (Read documentation and example)prefix
- adding prefix in file name backups.filename
- positionprefix
andtime
in file name.%p
replacedprefix
and%t
replaced current time, %n replaced device namekey
- Private Key for used SSH Authorized, need saved private key in folder./keys
. (if need used SSH keys, needpassword
filed delete or set""
)clearstring
- Specify the character to start with the line to delete.hook
- Execute command in os.
Many defaults can be changed globally in the config file pupirka.config.json
.
A device can have three (3) states.
skip
if no need backup, if time last backup less thanevery
(timefilelastbackup < every)error
if when doing backup device return error (connected ssh, connected parent, execute command, create file and etc...)backup
Good job, backup successfully
this string can be used next arguments
%name
- name device (from filename).%parent
- Parent if connected via ssh ssh port forward.%filename
- filename backup%address
- Address Device%portssh
- Port ssh Device
Pupirka NOT Wait execute command for devices.
If pupirka execute and file pupirka.config.json
not found, pupirka created config and set all default parameter
format: json
{
"devicedefault": {
"clearstring":"",
"command": "/export",
"every": 3600,
"filenameformat": "%p%t.rcs",
"key": "",
"portshh": 22,
"prefix": "",
"rotate": 730,
"timeformat": "20060102T1504",
"timeout": 10,
"hook": {
"backup": "",
"error": "",
"skip": ""
}
},
"git": {
"branch": "master",
"password": "",
"user":"Pupirka",
"email": "vk@mikrotik.me",
"remote": ""
},
"log": {
"format": "text",
"maxday": 1
},
"path": {
"backup": "./backup",
"devices": "./device",
"key": "./keys",
"log": "./log"
},
"process": {
"max": 10
},
"global": {
"hook": {
"post": "",
"pre": ""
},
onlyone: false
}
}
Sub Categories:
devicedefault
- default parameter used if not set in devices json file configlog
- global parameter for loggingpath
- directoriesprocess
- limits for pupirka
When Pupirka reads device parameters, if in devices json files not set parameter Pupirka used default value from config. Even if you did not set in the global config, these parameters and values are stored in the code Pupirka.
Clone current remote repo, Commit and Push remote
branch
- need issetremote
- url to remote repo
format
- the logging format can bejson
ortext
.maxday
- how many days can be recorded in one file.
Pupirka created all folder if not found.
backup
- folder for save backupdevices
- folder used for find your devices. Your needed create json file devices in this folder.key
- Pupirka find in this folder Private Keys for Auth devices.log
- Folder for save all log.
max
- in order not to overload the CPU, Pupirka it will back up in groups of the specified count.
other parameter
onlyone
true or false. Running only one application pupirka
Running and wait execute custom command.
pre
running before backupspost
running after all backups
Used specified Golang format
- Year -
2006
= result2020
,06
= result20
- Mount -
01
= result05
,1
= result5
- Day -
02
= result07
,2
= result7
- Hours -
03
= result05
,3
= result5
,15
= result17
- Minutes -
04
= result09
,4
= result9
- Seconds -
05
= result07
,5
= result7
Examples: datetime 2020-09-04:22:15:01
`timefomat` = "20060102T1504" #result 20200904T2215 this default
`timefomat` = "2006y01m02T15h04m" #result 2020y09m04T22h15m
`timefomat` = "2006-01-02 150405" #result 2020-09-04 221501
`timefomat` = "2006-01-2 150405" #result 2020-09-4 221501
`timefomat` = "2006-01-2 30405" #result 2020-09-4 101501
Please read documentation golang for time format loyuot