Coder Social home page Coder Social logo

Comments (15)

asifbacchus avatar asifbacchus commented on June 9, 2024 1

The script doesn't do anything special with that parameter, it simply dumps it into the BORG_REPO environment variable for borg to consume. According to an old issue in the borg github repo, you must use the ssh://... syntax or borg will ignore a custom port. Therefore, give this a shot:

borgConnectRepo="ssh://[email protected]:22222/backup/servers/mailcow.example.org/"

I hope that will fix things. This is a new one for me too, I've never used borg with a custom port so I'm interested if this fixes things for you. If it does, I'll update the documentation for the script and credit you :-)

from mailcowbackup.

asifbacchus avatar asifbacchus commented on June 9, 2024

Hey, sorry to hear you are having problems using the script. I have just pushed an updated script (posix shell instead of BASH) and cleaned up the config file structure so it's more like an INI file. Perhaps that will help you? I'd suggest cloning the new repo and using the new script.

What have you tried for your borgBaseDir?

The borg base directory is the directory where BORG stores its information. This has nothing to do with the script but needs to be forwarded to borg for it to work properly. Information can be found in the borg documentation here.

Here's the catch -- I always manually install borg from source so I get the newest version since the repo versions are usually pretty old. So, when I do the install manually I always know my base directory. I don't know how the repo packages handle the base directory, but I'd assume they stick to the borg defaults which are $HOME and ~$USER.

Are you running borg under your root account? Try a quick check if that's the case: In your /root/ directory, do you see /.cache/borg/ and /.config/borg/ directories? If so, your 'base directory' is your /root/ directory and you can use that. You might be able to simply use $HOME.

Assuming you use the latest script I just updated, then in your backup.details file you can try the following:

# option 1
borgBaseDir="/root"
# option 2
borgBaseDir="$HOME"

Let me know if that gets things up and running.

from mailcowbackup.

andreas5232 avatar andreas5232 commented on June 9, 2024

Thank you very much for your quick response and the new version of MailcowBackup you have just released. Unfortunately I was yet unable to test the new release, because I just get an ./backup.sh: Line 89: [:: Integer expression expected. error when running it. But this doesn't seem to be the root cause.

Logfile says: [ERROR] 131: details:borgKeyfileLocation file or directory does not exist.

I have installed borgbackup package on my Ubuntu system, but there is no /root/.config/borg directory. Yes, I am trying to run MailcowBackup and borgbackup as root, since I haven't set up any specific users on this machine yet. I'm still not sure what the correct borgBaseDir would be in this case. Maybe it is different because my backup target is a remote host reached via SSH?

Thanks in advance for your support! :)

from mailcowbackup.

asifbacchus avatar asifbacchus commented on June 9, 2024

Here's a silly question, but bear with me: Have you created a remote borg repo? The script does NOT create repos, you need to have an existing one. If you have created a repo manually, then can you do a manual borg backup of some dummy files to that repo? If you can, then we can search for the hidden borg directories and we will discover the proper baseDir. If you need help creating a remote borg repo, let me know and I can send you some instructions or the borg documentation is very good also.

Let me know and we can work from there. Also, give me a few hours, I will spin-up a Ubuntu VM and try testing things out to see if I can duplicate what's going on.

from mailcowbackup.

andreas5232 avatar andreas5232 commented on June 9, 2024

That's a good hint!
Yes, it's a remote borg repo that I've already created on the remote machine, but I've never backed up files from the Mailcow machine to the remote one yet. I will try to backup some files directly with borg to the remote machine to identify the needed baseDir variable.

from mailcowbackup.

asifbacchus avatar asifbacchus commented on June 9, 2024

Just following up, did you get this sorted out? If not, I have a little spare time and can spin-up an Ubuntu VM and try to dig into your issue a little more?

from mailcowbackup.

andreas5232 avatar andreas5232 commented on June 9, 2024

Thanks for the follow up. Unfortunately I haven't got it working yet.

After using borg directly from Shell on a fresh Ubuntu server, I get the following files within ~/.config:

.config/borg/security/6670ac843d6c0fd0d86dae23ed2f818b81113d34e4b032f5fac4dade3a49d94e
.config/borg/security/6670ac843d6c0fd0d86dae23ed2f818b81113d34e4b032f5fac4dade3a49d94e/nonce
.config/borg/security/6670ac843d6c0fd0d86dae23ed2f818b81113d34e4b032f5fac4dade3a49d94e/location
.config/borg/security/6670ac843d6c0fd0d86dae23ed2f818b81113d34e4b032f5fac4dade3a49d94e/key-type
.config/borg/security/6670ac843d6c0fd0d86dae23ed2f818b81113d34e4b032f5fac4dade3a49d94e/manifest-timestamp
.config/borg/security/6670ac843d6c0fd0d86dae23ed2f818b81113d34e4b032f5fac4dade3a49d94e/tam_required

I think that's not what your script expects as baseDir?

from mailcowbackup.

asifbacchus avatar asifbacchus commented on June 9, 2024

Seems borg is using its defaults, which is $HOME. This is explained in the borg documentation:

BORG_BASE_DIR
Defaults to $HOME or ~$USER or ~ (in that order). If you want to move all borg-specific folders to a custom path at once, all you need to do is to modify BORG_BASE_DIR: the other paths for cache, config etc. will adapt accordingly (assuming you didn’t set them to a different custom value).

However, since you are executing via the script, you need to supply this default anyways. You can use the environment variable, but I'd suggest expanding the path manually. I would assume you are running borg as root? If so, $HOME = '/root' therefore I'd update your backup.details file as follows:

borgBaseDir="/root"

You could also try the following and it should expand properly:

borgBaseDir="$HOME"

Let me know if that works.

from mailcowbackup.

andreas5232 avatar andreas5232 commented on June 9, 2024

At least the error message changed now. Using '/root' and '$HOME' makes no difference here.
The shell says:
./backup.sh: line 89: [: : unary operator expected
The backup.log says:
[ERROR] 131: details:borgKeyfileLocation file or directory does not exist.
But since I'm using a repokey, I'd expect that this config option doesn't matter.
Do I still have to specify a valid borgKeyfile?

Thanks for your support!

from mailcowbackup.

asifbacchus avatar asifbacchus commented on June 9, 2024
  1. Unary operator expected: I forgot to initialize that variable as zero... I'll fix it in an upcoming commit, but you can ignore that since it's not important.
  2. Since you are using repokey, did you comment out the borgKeyfileLocation line in the backup.details file? If you're not using it, you need to be absolutely sure that line is empty so the variable is not set, commenting it out is the easiest way:
#borgKeyfileLocation=

Note the # before the variable name. That way the script for sure will ignore that variable. It's actually exactly how I use the script so that hopefully will solve your issue.

from mailcowbackup.

andreas5232 avatar andreas5232 commented on June 9, 2024

Alright. It obviously just wasn't clear to me, that those variables have to be unset, if they are not used. I only tried it with an empty string.

Now I'm getting a different borg specific error, because my backup server is not available on standard port 22. Is there a possibility to specify a different SSH port?
Remote: ssh: connect to host backup-server.example.org port 22: No route to host

from mailcowbackup.

asifbacchus avatar asifbacchus commented on June 9, 2024

It should be pretty easy, actually, based on the borg documentation. It depends on what you are using for your 'borgConnectRepo' parameter value. Let's assume the following:

server: backup-server.example.org
custom port: 2022
repo name: myBorgRepo (assuming at the root)
username: andreas

You should be able to use something like this:

borgConnectRepo="[email protected]:2022/myBorgRepo"

Does that work? If not, please give me an example of what you are using for your 'borgConnectRepo' value.

from mailcowbackup.

andreas5232 avatar andreas5232 commented on June 9, 2024

I already had that idea before I read your reply, but unfortunately it doesn't seem to work:

borgConnectRepo="[email protected]:22222/backup/servers/mailcow.example.org/"

results in the following backup.log

[INFO] Pre-backup tasks completed, calling borgbackup 
[INFO] Executing borg backup operation
Remote: ssh: connect to host backup-server.example.org port 22: No route to host
Connection closed by remote host. Is borg working on the server?
terminating with error status, rc 2

Do I need another syntax for borgConnectRepo?

from mailcowbackup.

andreas5232 avatar andreas5232 commented on June 9, 2024

Yeah! It's finally working now. 🎉

Maybe you also want to add a hint for remote repo's to accept the servers SSH fingerprint before running the script via cronjob ;-). Totally forgot about that and there is no info showing up within the backup.log as the prompt gets displayed interactively on the shell.

The backup job hasn't finished yet, but as the script is still running and producing visible traffic to my backup server, I bet it's running fine now.

Thanks again for your awesome support!

from mailcowbackup.

asifbacchus avatar asifbacchus commented on June 9, 2024

Great to hear! I will update the documentation and put a few examples in there also. And yes, I didn't think about the fingerprint issue, I just assumed it would be taken care of when the repo was created outside of the script, but I should make that clearer. Thanks for the suggestions.
Glad we got that sorted out, all the best!

from mailcowbackup.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.