Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cya does not handle directory names with spaces #12

Open
cspaniard opened this issue Apr 3, 2018 · 20 comments
Open

cya does not handle directory names with spaces #12

cspaniard opened this issue Apr 3, 2018 · 20 comments
Labels

Comments

@cspaniard
Copy link

The following setting makes cya fail.

BACKUP_DIRECTORIES="/sys/ /home/dsanroma/directory with spaces/"
[...]
/sys/ ... yes
/home/dsanroma/directory ... skipping - DOESN'T EXIST!
with ... skipping - DOESN'T EXIST!
spaces/ ... skipping - DOESN'T EXIST!
[...]

Similar things happen with MYDATA_xxxx settings with spaces in them.

Maybe the string could be broken up with regex instead of just white spaces.

just a though

@cleverwise
Copy link
Owner

Have you tried putting a back slash?

/home/dsanroma/directory\ with\ spaces/

@cspaniard
Copy link
Author

Yes I did... no dice... ;(

@cleverwise
Copy link
Owner

Okay. Well that needs to be patched and honestly has the highest priority out of all these issues.

@cspaniard
Copy link
Author

Makes sense, of course... Bugs first, features later... ;)

I will keep on testing different things and scenarios...

@cleverwise
Copy link
Owner

cleverwise commented Apr 3, 2018

All you need to do is try \\

/home/dsanroma/directory\\ with\\ spaces/

@cleverwise
Copy link
Owner

cleverwise commented Apr 3, 2018

The double slashes got edited by github (makes sense) so in case you only check email first and not my revised post it is backslash backslash together or double backslashes. That will allow a slash to occur and spaces to work.

So /directory(backslashbackslashspace)with(backslashbackslashspace)spaces/

@cspaniard
Copy link
Author

cspaniard commented Apr 4, 2018

Tested and it works!!!!
the /home/dsanroma/directory\\ with\\ spaces/ syntax works great!!!

Since it is not all that intuitive to have to "escape twice", maybe the syntax could be explained / specified in the cya configfile command.

What do you think ?

@cleverwise
Copy link
Owner

Yeah I already added it to the configfile information in 2.3.1+ dev/2.4

@cleverwise
Copy link
Owner

I added the question label since there is nothing to change code wise. Also using labels to keep track of what has been done. You have been emailed a dev copy 2.3.1 for the three enhancements.

@cspaniard
Copy link
Author

cspaniard commented Apr 5, 2018

Checks that "double-back-slash explanation" is present in:

BACKUP_DIRECTORIES Explanation and Examples, both documented
EXCLUDE_/xxxx/ Explanation and Examples, both documented
BACKUP_FILES Explanation and Examples, both documented
MYDATA_xxxx Explanation and Examples, both documented

However, there is an error in this example provided in the configfile command. According to the documentation, it should not include the leading forward slash.

EXCLUDE_/var/="/my\\ directory\\ with\\ spaces/"

should be

EXCLUDE_/var/="my\\ directory\\ with\\ spaces/"

@cleverwise
Copy link
Owner

Good catch and a typo. Fixed in 2.3.2.

@cspaniard cspaniard reopened this Apr 16, 2018
@cspaniard
Copy link
Author

The initial tests showed that the command cya directories does handle the names with spaces correctly if \\ are provided before the spaces. So far, so good.

However, when I tried to run the backup with a cya save command, I got the following errors on directories with spaces. Of course the \\ are there, otherwise cya directories would not work either.

Backing up /home/dsanroma/directory with spaces/ ... rsync: link_stat "/home/dsanroma/directory" failed: No such file or directory (2)
rsync: link_stat "/home/dsanroma/with" failed: No such file or directory (2)
rsync: change_dir "/home/cya/points/2/home/dsanroma" failed: No such file or directory (2)
rsync: link_stat "/home/dsanroma/with" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
 complete
Backing up /initrd.img ...  complete
Backing up /initrd.img.old ...  complete
Backing up /vmlinuz ...  complete
Backing up /vmlinuz.old ...  complete
Backing up /etc/hosts ...  complete
Backing up /etc/bash_completion.d/git-prompt ...  complete
Backing up /home/dsanroma/file with spaces ... rsync: link_stat "/home/dsanroma/file" failed: No such file or directory (2)
rsync: link_stat "/home/dsanroma/with" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
 complete

@cleverwise
Copy link
Owner

Confirmed. This will take time to address as spaces fixed in one area error out others. The script wasn't designed for spaces and even though function calls are used there are multiple lines that need addressing.

As stated I get it working in one area and it fails in another. I am still working out the most efficient way to code that will work in all areas with out having to rewrite whole blocks of code. It isn't proving easy.

Thus far all attempts have failed even changing out spaces for things like []. It is beginning to look like this feature may have to wait some. It is turning into a major update. We shall see.

@cleverwise
Copy link
Owner

Okay this is now working in v2.3.5+ with save and keep commands. The mydata command is still in processing and will add more logic later. This hasn't been the most straightforward alternations. I'll let you know when I get more time but for a bit other projects have higher priority. I still need to recode the exclude with spaces too.

I am changing the format to [] for spaces and eliminating \ at least in the quotes. We shall see about the profile names. It is much easier than having to deal with multiple slashes.

At least I know what to do but need more time.

@cleverwise
Copy link
Owner

This appears to be working 2.3.5+ but needs more testing.

@cspaniard
Copy link
Author

Tested on 2.3.5 and it fails for me.

OVERRIDE_BACKUP_DIRECTORIES="/etc/"
BACKUP_DIRECTORIES="/home/dsanroma/directory[]with[]spaces/"
$ cya save
☀ Cover Your Ass(ets) v2.3.5 ☀ 

ACTION ⯮ Standard Backup

Checking sudo permissions...
EN: EXCLUDE_/etc/
Backing up /etc/ ... complete
EN: EXCLUDE_/home/dsanroma/directory[]with[]spaces/
Backing up /home/dsanroma/directory with spaces/ ...rsync: mkdir "/home/cya/points/3/home/dsanroma/directory with spaces" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(674) [Receiver=3.1.1]
 complete
Backing up /initrd.img ...  complete
Backing up /initrd.img.old ...  complete
Backing up /vmlinuz ...  complete
Backing up /vmlinuz.old ...  complete
Write out date file ... complete
Update rotation file ... complete

@cleverwise
Copy link
Owner

I am not surprised.

The reason is because CYA was originally only creating one directory deep. Since you have specified three /home/dsanroma/directory with spaces/ this is failing as /home/ and then inside that /dsanroma/ need to be created first. So of course /directory with spaces/ fails as the parents are missing.

No problem. I'll just add the -p flag to mkdir shortly as that is simple to do.

@cleverwise
Copy link
Owner

I did briefly look at this however there is a slight issue.

The save and keep commands are really more for system directories. When directories are created they get the owner of root. Which is correct for system directories. I could run mkdir differently but that wouldn't work as desired.

You should stick user files into the mydata command so that they will correctly get the right owner. This is one of the reasons I wrote the mydata command. So one can create the destination directory with the necessary ownership. Then when restoring the correct information will be used.

I could create a check original ownership and if not root change directory to that user but that seems unnecessary when one can use the mydata command.

@cspaniard
Copy link
Author

Ok... it makes sense...

I will test it out in a similar way but with system folder with spaces and multiple levels down owned by root.

I will also make deeper tests with mydata in similar fashion.

@HarriL
Copy link

HarriL commented Jan 1, 2019

Did you fix this one?

Some possible fixes w/ single quotes should work:

  1. Add single quote (') around the dir name and b/w the double quotes
    BACKUP_DIRECTORIES="'/home/dsanroma/directory[]with[]spaces/'"

  2. In some scrips you may need to add \ or \ before the single quote
    BACKUP_DIRECTORIES="'/home/dsanroma/directory[]with[]spaces/'"
    or
    BACKUP_DIRECTORIES="\'/home/dsanroma/directory[]with[]spaces/\'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants