I have a working folder with a bunch of files, there are projects of different programs and I would like to write a script to automate this process.
Tell me how you can make a list of files in a folder and copy these files to the backups/date folder using the script.sh?

3 Answers 3

Script:
#!/Bin/sh
tar -cvzf/mnt/backup_device/dir/backup - $(date +"% d.% m.% y").tar.gz/var/www/dir/files

/mnt/backup_device/dir/- replace with backup folder
 /var/www/dir/files - the folder that we backup |
Then it’s in crowns.For example, every day at 5 am:
0 5 * * * sh /home/backupdata.sh
  • from such happiness a person will now completely fall into nirvana) – European13 Aug 14 '19 at 00:35
  • European13, well, let
    Then will suffer more
    – Dead Duck Aug 14 '19 at 00:38
  • Thank you This option is many times simpler than what I wanted to do, but I have to change something in my workspace. – Mysterious Lego Aug 14 '19 at 01:01
  • Dead Duck, that's why I switched to Linux, I like to suffer and sex with machines))) – Mysterious Lego Aug 14 '19 at 01:01
zip the folder, copy to the desired location.
which of these causes difficulties?
  • Paul Plotnikov @paulenot
    User Status - Kettle

    this
    – European13 Aug 14 '19 at 00:25
  • [[inoise]], daladna, we all once come across something new)) – Transvestite61 Aug 14 '19 at 00:26
  • [[DevMan]], but we google something) – European13 Aug 14 '19 at 00:27
  • [[inoise]], but not only all) – Transvestite61 Aug 14 '19 at 00:29
  • Every day I work in a million programs and I want to put it into autorun so that backup is saved every day. – Mysterious Lego Aug 14 '19 at 00:53
  • [[inoise]], I googled and did not find what I was looking for, a lot of all sorts of programs and solutions for my tasks.

    I know that you can copy cp
    make a list in ls(but how recursively?)

    in my folder there are a lot of files and the backups folder, here you need to put all the files by date except the backups folder itself(how to exclude it from the list also has no idea)

    status - kettle, immediately indicated)
    – Mysterious Lego Aug 14 '19 at 00:58
  • [[paulenot]], read the commands through man) `man cp`, for example.you don’t need a list, but if you really want to, put a tree.It’s easy to exclude it - learn the syntax of bash) – European13 Aug 14 '19 at 01:04
1.`cp -R from to`
2.`tar -zcvf archive-name.tar.gz directory-name`
3.be a normal person, store projects in git and upload them to the server from there
  • I have not yet mastered the git, I just set up some programs on one folder and there all the saves are there. – Mysterious Lego Aug 14 '19 at 00:52
  • Don’t completely trust git.It is too politicized and one day your projects may be blocked without the possibility of downloading. – Rushing Mafia Aug 14 '19 at 01:27
  • [[shurikaltai]], and you, look, from these - from alarmists?) who heard about one or two cases and now beats in hysterics"my little private repository will be blocked by nobody, panic!" – European13 Aug 14 '19 at 01:36