I use Ubuntu 16.04 (xenial) with Bash 4.3.48(1) and zip
3.0.
In a file containing a bash script (#!/bin/bash
) with many different functions, I also have this function used to create a full database backup + document root backup in one zip file:
imb() {
drt="/var/www/html"
date="$(date +%F-%T)"
mysqldump -u root -p --all-databases | zip "$drt/db-$date.zip" - # Note the hyphen before this comment;
zip -r "all_zipped-$date.zip" "$drt"/ -x "*/cache/*"
rm -f "$drt/db-$date.zip"
}
I sourced the aformentioned file (source ~/function.sh
) and executed imb
in debug mode (set -x
):
I was prompted for DB password and then some time passed (indicating DB backup created). Also, a verbose zip appeared (too long to paste or trace in terminal) indicating everything under document root was zipped.
Yet no backup appears under /var/www/html/
.
My question
Due to a comment I feel I should ask two questions, which I found similar but actually different:
Where did zip put my files (assuming this isn't a"file creation" in the sense of manual creation as with
touch
, for example)? Of course, files created and located somewhere by a processes, shouldn't necessarily be owned by my user.How could I find out where the the last file created by my current user, was located?
I expected it to be located in /var/www/html/
:
zip -r "all_zipped-$date.zip" "$drt"/ -x "*/cache/*"
but wasn't. I don't know an efficient way to know where it was created without running on the entire file tree of my system up from root (/
), as this could take hours in that machine.
Update
When writing this question I visited my home dir ($HOME/
), there I found the file, but I don't know why it was created there instead under document root.
sudo
it isn't distinguishable (both the manual file creation and the function create a file owned by root).