Notes: * Adjust the find command to your own filters. * The -P flag forces to keep absolute paths in the tarball, so that you can be sure that the exact same file hierarchy will be created on the second machine.
create an archive of files with access time older than 5 days, and remove original files.
Requires the GNU tar ignore zeros option. http://www.gnu.org/software/tar/manual/html_section/Blocking.html Show Sample Output
tar options may change ;) c to compress into a tar file, z for gzip (j for bzip) man tar -print0 and -0t are usefull for names with spaces, \, etc.
I recently found myself with a filesystem I couldn't write to and a bunch of files I had to get the hell out of dodge, preferably not one at a time. This command makes it possible to pack a bunch of files into a single archive and write it to a remote server.
creates a tar.gz with a name like: backup20090410_173053.tar.gz of a given directory. this file was made 10 April 2009 at 5:30:53pm see date's man page to customize the timestamp format
command to decrypt:
openssl enc -aes-256-cbc -d < secret.tar.enc | tar x
Of course, don't forget to rm the original files ;) You may also want to look at the openssl docs for more options.
This command tar?s up a directory and sends the output to gzip, showing a rate of 223MB/s.
This may require you installing the pv command.
For debian based users out there:
sudo aptitude install pv
Show Sample Output
Use `tar xj` for bzip2 archives.
in fact, I want to know, how to only get the modified files.
tar does not have a -mtime option as find. tar appends all the file to an existing tar file.
If you want to exclude only one file or directory you should use as --exclude=file_or_directory
Note: the tar archive must not exist in order to create it. If exists it will only be updated and no already existent files in present search will still remain in the tar archive. The update option has to be used instead of create because the command tar may be executed more than once depending on the number of arguments that find throws. You can see maximum number of arguments with 'getconf ARG_MAX'
First, use find
to find directories exactly one level below current directory, then create a tar file using the directory as the basename.
A useful bash function: gztardir() { if [ $# -ne 1 ] ; then echo "incorrect arguments: should be gztardir " else tar zcvf "${1%/}-$(date +%Y%m%d-%H%M).tar.gz" "$1" fi }
I use this all the time for taking manual backups of stuff i want to keep but not important enough to backup regularly.
Create backup (.tar.gz) for all first-level directory from current dir. Show Sample Output
Clone a partion with tar.
and you quickly know the files you changed Show Sample Output
If you give tar a list of filenames, it will not add the directories, so if you don't care about directory ownership or permissions, you can save some space. Tar will create directories as necessary when extracting. This command is limited by the maximum supported size of the argument list, so if you are trying to tar up the whole OS for instance, you may just get "Argument list too long".
You set the file/dirname transfer variable, in the end point you set the path destination, this command uses pipe view to show progress, compress the file outut and takes account to change the ssh cipher. Support dirnames with spaces. Merged ideas and comments by http://www.commandlinefu.com/commands/view/4379/copy-working-directory-and-compress-it-on-the-fly-while-showing-progress and http://www.commandlinefu.com/commands/view/3177/move-a-lot-of-files-over-ssh Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: