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

Make option for use only last directory name in backup archive structure #129

Open
MurzNN opened this issue Feb 14, 2020 · 3 comments
Open

Comments

@MurzNN
Copy link

MurzNN commented Feb 14, 2020

At now in backup archive there are stored full path to backup items, so if I backup something like "/home/alice/myclients/client1/myprojects/project2", files are stored in archive in same long subfolder structure.

Will be good to have option to use only last directory name as folder name in destination archive file, can you add it? Also glad to see option to set custom name for each backup item.

@MurzNN
Copy link
Author

MurzNN commented Feb 16, 2020

Setting custom name for each backup item can be implemented via Bash associative arrays, here is example:

declare -A backup_items
backup_items[etc]="/etc"
backup_items[mpd-logs]="/var/lib/mpd/"

@ccztux
Copy link
Owner

ccztux commented Dec 30, 2020

At now in backup archive there are stored full path to backup items, so if I backup something like "/home/alice/myclients/client1/myprojects/project2", files are stored in archive in same long subfolder structure.

Will be good to have option to use only last directory name as folder name in destination archive file, can you add it? Also glad to see option to set custom name for each backup item.

A possible solution could be to use the following tar option:

-C, --directory=DIR
    change to directory DIR 

I have not tested this, but i think the following should work. Backup all files and folders in the /etc and /home directory (relative paths):

backup_items=(
"-C /etc/ ."
"-C /home/ ."
)

I think it could be an issue, if there are items with the same name in these directories.

@ccztux
Copy link
Owner

ccztux commented Dec 30, 2020

Setting custom name for each backup item can be implemented via Bash associative arrays, here is example:

declare -A backup_items
backup_items[etc]="/etc"
backup_items[mpd-logs]="/var/lib/mpd/"

glsysbackup currently supports bash version >= 3. Associative arrays are a feature pronounced in bash version 4. I will think about dropping support of bash version < 4.

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

No branches or pull requests

2 participants